diff --git a/api-report/sequence.api.md b/api-report/sequence.api.md index f949b0047008..14303c1c2a22 100644 --- a/api-report/sequence.api.md +++ b/api-report/sequence.api.md @@ -7,7 +7,6 @@ import { BaseSegment } from '@fluidframework/merge-tree'; import { Client } from '@fluidframework/merge-tree'; import { Deferred } from '@fluidframework/common-utils'; -import { FluidObject } from '@fluidframework/core-interfaces'; import { IChannelAttributes } from '@fluidframework/datastore-definitions'; import { IChannelFactory } from '@fluidframework/datastore-definitions'; import { IChannelServices } from '@fluidframework/datastore-definitions'; @@ -17,8 +16,6 @@ import { IEvent } from '@fluidframework/common-definitions'; import { IEventThisPlaceHolder } from '@fluidframework/common-definitions'; import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions'; import { IFluidHandle } from '@fluidframework/core-interfaces'; -import { IFluidLoadable } from '@fluidframework/core-interfaces'; -import { IFluidObject } from '@fluidframework/core-interfaces'; import { IFluidSerializer } from '@fluidframework/shared-object-base'; import { IInterval } from '@fluidframework/merge-tree'; import { IJSONSegment } from '@fluidframework/merge-tree'; @@ -673,7 +670,7 @@ export class SparseMatrix extends SharedSegmentSequence { static create(runtime: IFluidDataStoreRuntime, id?: string): SparseMatrix; static getFactory(): IChannelFactory; // (undocumented) - getItem(row: number, col: number): Jsonable>; + getItem(row: number, col: number): Jsonable; // (undocumented) getPositionProperties(row: number, col: number): PropertySet; // (undocumented) diff --git a/common/lib/common-definitions/package-lock.json b/common/lib/common-definitions/package-lock.json index c9548990b449..9f08e8af7399 100644 --- a/common/lib/common-definitions/package-lock.json +++ b/common/lib/common-definitions/package-lock.json @@ -182,9 +182,9 @@ "dev": true }, "@fluidframework/eslint-config-fluid": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.26.0.tgz", - "integrity": "sha512-odm+o74yEZU3hFqBag6jPtdLZxv2ponFNGGe/1ZzHw/wVDDDy4G07Kjbai+76t4TH2+dTOWaTjWOFt9h68bU1A==", + "version": "0.27.0-51301", + "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.27.0-51301.tgz", + "integrity": "sha512-P/+BCF8vAwoSBUrkTYizg5iKaRnE0NNEVieur1Lp1HjzvRwKr/UYgVd6EEZ2hZ7SlpB2zMCcGuuccm6uX1A/ow==", "dev": true, "requires": { "@rushstack/eslint-config": "^2.5.1", diff --git a/common/lib/common-definitions/package.json b/common/lib/common-definitions/package.json index 33c226759b04..e7c0c3db45ac 100644 --- a/common/lib/common-definitions/package.json +++ b/common/lib/common-definitions/package.json @@ -42,7 +42,7 @@ "@fluidframework/build-common": "^0.23.0", "@fluidframework/build-tools": "^0.2.54658", "@fluidframework/common-definitions-0.20.0": "npm:@fluidframework/common-definitions@0.20.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@typescript-eslint/eslint-plugin": "~5.9.0", diff --git a/common/lib/common-utils/package-lock.json b/common/lib/common-utils/package-lock.json index 7d607ed2cc1a..1e52c057bb7c 100644 --- a/common/lib/common-utils/package-lock.json +++ b/common/lib/common-utils/package-lock.json @@ -584,9 +584,9 @@ } }, "@fluidframework/eslint-config-fluid": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.26.0.tgz", - "integrity": "sha512-odm+o74yEZU3hFqBag6jPtdLZxv2ponFNGGe/1ZzHw/wVDDDy4G07Kjbai+76t4TH2+dTOWaTjWOFt9h68bU1A==", + "version": "0.27.0-51301", + "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.27.0-51301.tgz", + "integrity": "sha512-P/+BCF8vAwoSBUrkTYizg5iKaRnE0NNEVieur1Lp1HjzvRwKr/UYgVd6EEZ2hZ7SlpB2zMCcGuuccm6uX1A/ow==", "dev": true, "requires": { "@rushstack/eslint-config": "^2.5.1", diff --git a/common/lib/common-utils/package.json b/common/lib/common-utils/package.json index ca9d01ad6ccf..a0c403d2287e 100644 --- a/common/lib/common-utils/package.json +++ b/common/lib/common-utils/package.json @@ -85,7 +85,7 @@ "@fluidframework/build-common": "^0.23.0", "@fluidframework/build-tools": "^0.2.54658", "@fluidframework/common-utils-0.32.1": "npm:@fluidframework/common-utils@0.32.1", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/base64-js": "^1.3.0", diff --git a/common/lib/container-definitions/package-lock.json b/common/lib/container-definitions/package-lock.json index f9e29d460ec7..f2d206eff735 100644 --- a/common/lib/container-definitions/package-lock.json +++ b/common/lib/container-definitions/package-lock.json @@ -504,9 +504,9 @@ } }, "@fluidframework/eslint-config-fluid": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.26.0.tgz", - "integrity": "sha512-odm+o74yEZU3hFqBag6jPtdLZxv2ponFNGGe/1ZzHw/wVDDDy4G07Kjbai+76t4TH2+dTOWaTjWOFt9h68bU1A==", + "version": "0.27.0-51301", + "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.27.0-51301.tgz", + "integrity": "sha512-P/+BCF8vAwoSBUrkTYizg5iKaRnE0NNEVieur1Lp1HjzvRwKr/UYgVd6EEZ2hZ7SlpB2zMCcGuuccm6uX1A/ow==", "dev": true, "requires": { "@rushstack/eslint-config": "^2.5.1", diff --git a/common/lib/container-definitions/package.json b/common/lib/container-definitions/package.json index c91656819fb5..3e9e47378136 100644 --- a/common/lib/container-definitions/package.json +++ b/common/lib/container-definitions/package.json @@ -52,7 +52,7 @@ "@fluidframework/container-definitions-0.44.0": "npm:@fluidframework/container-definitions@0.44.0", "@fluidframework/container-definitions-0.45.0": "npm:@fluidframework/container-definitions@0.45.0", "@fluidframework/container-definitions-0.46.0": "npm:@fluidframework/container-definitions@0.46.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/common/lib/core-interfaces/package-lock.json b/common/lib/core-interfaces/package-lock.json index 5a779780ac80..ac0653010a3d 100644 --- a/common/lib/core-interfaces/package-lock.json +++ b/common/lib/core-interfaces/package-lock.json @@ -200,9 +200,9 @@ "dev": true }, "@fluidframework/eslint-config-fluid": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.26.0.tgz", - "integrity": "sha512-odm+o74yEZU3hFqBag6jPtdLZxv2ponFNGGe/1ZzHw/wVDDDy4G07Kjbai+76t4TH2+dTOWaTjWOFt9h68bU1A==", + "version": "0.27.0-51301", + "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.27.0-51301.tgz", + "integrity": "sha512-P/+BCF8vAwoSBUrkTYizg5iKaRnE0NNEVieur1Lp1HjzvRwKr/UYgVd6EEZ2hZ7SlpB2zMCcGuuccm6uX1A/ow==", "dev": true, "requires": { "@rushstack/eslint-config": "^2.5.1", diff --git a/common/lib/core-interfaces/package.json b/common/lib/core-interfaces/package.json index 8f43896639f2..59dc59b932fc 100644 --- a/common/lib/core-interfaces/package.json +++ b/common/lib/core-interfaces/package.json @@ -41,7 +41,7 @@ "@fluidframework/core-interfaces-0.40.0": "npm:@fluidframework/core-interfaces@0.40.0", "@fluidframework/core-interfaces-0.41.0": "npm:@fluidframework/core-interfaces@0.41.0", "@fluidframework/core-interfaces-0.42.0": "npm:@fluidframework/core-interfaces@0.42.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", diff --git a/common/lib/driver-definitions/package-lock.json b/common/lib/driver-definitions/package-lock.json index 60b62c904896..d87b41b1266a 100644 --- a/common/lib/driver-definitions/package-lock.json +++ b/common/lib/driver-definitions/package-lock.json @@ -348,9 +348,9 @@ } }, "@fluidframework/eslint-config-fluid": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.26.0.tgz", - "integrity": "sha512-odm+o74yEZU3hFqBag6jPtdLZxv2ponFNGGe/1ZzHw/wVDDDy4G07Kjbai+76t4TH2+dTOWaTjWOFt9h68bU1A==", + "version": "0.27.0-51301", + "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.27.0-51301.tgz", + "integrity": "sha512-P/+BCF8vAwoSBUrkTYizg5iKaRnE0NNEVieur1Lp1HjzvRwKr/UYgVd6EEZ2hZ7SlpB2zMCcGuuccm6uX1A/ow==", "dev": true, "requires": { "@rushstack/eslint-config": "^2.5.1", diff --git a/common/lib/driver-definitions/package.json b/common/lib/driver-definitions/package.json index 8d5398accd7d..02b731534ce8 100644 --- a/common/lib/driver-definitions/package.json +++ b/common/lib/driver-definitions/package.json @@ -47,7 +47,7 @@ "@fluidframework/driver-definitions-0.42.0": "npm:@fluidframework/driver-definitions@0.42.0", "@fluidframework/driver-definitions-0.43.0": "npm:@fluidframework/driver-definitions@0.43.0", "@fluidframework/driver-definitions-0.44.0": "npm:@fluidframework/driver-definitions@0.44.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@typescript-eslint/eslint-plugin": "~5.9.0", diff --git a/common/lib/protocol-definitions/package-lock.json b/common/lib/protocol-definitions/package-lock.json index 02ffc68d8a6f..674926138f08 100644 --- a/common/lib/protocol-definitions/package-lock.json +++ b/common/lib/protocol-definitions/package-lock.json @@ -181,9 +181,9 @@ "integrity": "sha512-seE/EADKV2cu4YZ9MuueCT/3t8Y4ehtVPow0yJyhy53r/OIB41/8G8tTH/sPVbIq1OhqKBPpvseotK67HrqU6A==" }, "@fluidframework/eslint-config-fluid": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.26.0.tgz", - "integrity": "sha512-odm+o74yEZU3hFqBag6jPtdLZxv2ponFNGGe/1ZzHw/wVDDDy4G07Kjbai+76t4TH2+dTOWaTjWOFt9h68bU1A==", + "version": "0.27.0-51301", + "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.27.0-51301.tgz", + "integrity": "sha512-P/+BCF8vAwoSBUrkTYizg5iKaRnE0NNEVieur1Lp1HjzvRwKr/UYgVd6EEZ2hZ7SlpB2zMCcGuuccm6uX1A/ow==", "dev": true, "requires": { "@rushstack/eslint-config": "^2.5.1", diff --git a/common/lib/protocol-definitions/package.json b/common/lib/protocol-definitions/package.json index 8a21b00f8808..250947a9c18d 100644 --- a/common/lib/protocol-definitions/package.json +++ b/common/lib/protocol-definitions/package.json @@ -39,7 +39,7 @@ "devDependencies": { "@fluidframework/build-common": "^0.23.0", "@fluidframework/build-tools": "^0.2.54658", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/protocol-definitions-0.1024.0": "npm:@fluidframework/protocol-definitions@0.1024.0", "@fluidframework/protocol-definitions-0.1025.1": "npm:@fluidframework/protocol-definitions@0.1025.1", "@fluidframework/protocol-definitions-0.1026.0": "npm:@fluidframework/protocol-definitions@0.1026.0", diff --git a/docs/.gdnbaselines b/docs/.gdnbaselines index 37cfc9f6d41f..1bb23e756e05 100644 --- a/docs/.gdnbaselines +++ b/docs/.gdnbaselines @@ -11,7 +11,9 @@ "552baaa9d24596ed82e97b538dbef8abfcc9a0a8a9fdc8d3423424bf003b4fa7": { "signature": "552baaa9d24596ed82e97b538dbef8abfcc9a0a8a9fdc8d3423424bf003b4fa7", "alternativeSignatures": [ - "b5f214e29b5462952a2841914ef8d1fc8141a9e8a69ea2b2be6c0cd409bf15d7" + "b5f214e29b5462952a2841914ef8d1fc8141a9e8a69ea2b2be6c0cd409bf15d7", + "f7352489c50aed5529c30f15f2d6e019dc840612ceb612ea5ffb44a0d994c641", + "956ef6761cd88e6cc39f6bd892c0e1e0719ac955d3e4bd5a52189ab9e64db97f" ], "target": "docs/themes/thxvscode/assets/js/bundle.js", "memberOf": [ @@ -27,7 +29,9 @@ "0d4fa60d5f0b4f1d15e59fc8d68612e8f79f722ef23af4b073a0167ab4878fd6": { "signature": "0d4fa60d5f0b4f1d15e59fc8d68612e8f79f722ef23af4b073a0167ab4878fd6", "alternativeSignatures": [ - "0c23128bddf2d4096ab21304a1026ea81637d87cf6c31a0ce9f56b97d03aad13" + "0c23128bddf2d4096ab21304a1026ea81637d87cf6c31a0ce9f56b97d03aad13", + "9ee87cd6cc4a7c3ee2b369ab55776beffe036908ab73e36bdc1ee30f78f925f4", + "b7a109924c97e48aae0751db9f9fae3963865ec0fcef79db223b22e1f72d8a20" ], "target": "docs/themes/thxvscode/assets/js/bundle.js", "memberOf": [ @@ -41,4 +45,4 @@ "type": null } } -} \ No newline at end of file +} diff --git a/examples/apps/collaborative-textarea/package.json b/examples/apps/collaborative-textarea/package.json index d0c99c6f5b09..eb74b400fc74 100644 --- a/examples/apps/collaborative-textarea/package.json +++ b/examples/apps/collaborative-textarea/package.json @@ -48,7 +48,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@fluidframework/test-utils": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", diff --git a/examples/apps/contact-collection/package.json b/examples/apps/contact-collection/package.json index 4e4b7d00e99e..449404b11da8 100644 --- a/examples/apps/contact-collection/package.json +++ b/examples/apps/contact-collection/package.json @@ -47,7 +47,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/apps/spaces/package.json b/examples/apps/spaces/package.json index ed57c3ea7f82..a9b5dc7bcd9b 100644 --- a/examples/apps/spaces/package.json +++ b/examples/apps/spaces/package.json @@ -59,7 +59,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/apps/view-framework-sampler/package.json b/examples/apps/view-framework-sampler/package.json index 249dc8126389..f4452a52e643 100644 --- a/examples/apps/view-framework-sampler/package.json +++ b/examples/apps/view-framework-sampler/package.json @@ -44,7 +44,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/data-objects/badge/package.json b/examples/data-objects/badge/package.json index 55316eb33bc8..b58200099b58 100644 --- a/examples/data-objects/badge/package.json +++ b/examples/data-objects/badge/package.json @@ -48,7 +48,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", "@types/react": "^16.9.15", diff --git a/examples/data-objects/canvas/package.json b/examples/data-objects/canvas/package.json index b45d949a5e86..e299ea78206d 100644 --- a/examples/data-objects/canvas/package.json +++ b/examples/data-objects/canvas/package.json @@ -47,7 +47,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/data-objects/clicker-react/clicker-context/package.json b/examples/data-objects/clicker-react/clicker-context/package.json index 3367a6a2b344..c60d07d38d87 100644 --- a/examples/data-objects/clicker-react/clicker-context/package.json +++ b/examples/data-objects/clicker-react/clicker-context/package.json @@ -45,7 +45,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/data-objects/clicker-react/clicker-function/package.json b/examples/data-objects/clicker-react/clicker-function/package.json index 300aa9e63174..c78a00938296 100644 --- a/examples/data-objects/clicker-react/clicker-function/package.json +++ b/examples/data-objects/clicker-react/clicker-function/package.json @@ -45,7 +45,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/data-objects/clicker-react/clicker-react/package.json b/examples/data-objects/clicker-react/clicker-react/package.json index d5c528c4f704..495d8a14b3df 100644 --- a/examples/data-objects/clicker-react/clicker-react/package.json +++ b/examples/data-objects/clicker-react/clicker-react/package.json @@ -47,7 +47,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@fluidframework/test-utils": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", diff --git a/examples/data-objects/clicker-react/clicker-reducer/package.json b/examples/data-objects/clicker-react/clicker-reducer/package.json index 391341553f7b..735196c97b68 100644 --- a/examples/data-objects/clicker-react/clicker-reducer/package.json +++ b/examples/data-objects/clicker-react/clicker-reducer/package.json @@ -46,7 +46,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@fluidframework/test-utils": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", diff --git a/examples/data-objects/clicker-react/clicker-with-hook/package.json b/examples/data-objects/clicker-react/clicker-with-hook/package.json index cdbcbeb381fe..6c0e4cdab650 100644 --- a/examples/data-objects/clicker-react/clicker-with-hook/package.json +++ b/examples/data-objects/clicker-react/clicker-with-hook/package.json @@ -46,7 +46,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@fluidframework/test-utils": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", diff --git a/examples/data-objects/clicker/package.json b/examples/data-objects/clicker/package.json index 6b47a903596b..439006de2cb1 100644 --- a/examples/data-objects/clicker/package.json +++ b/examples/data-objects/clicker/package.json @@ -49,7 +49,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@fluidframework/test-utils": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", diff --git a/examples/data-objects/client-ui-lib/package.json b/examples/data-objects/client-ui-lib/package.json index 662f6f9b4967..e775070aaab0 100644 --- a/examples/data-objects/client-ui-lib/package.json +++ b/examples/data-objects/client-ui-lib/package.json @@ -68,7 +68,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", "@types/debug": "^4.1.5", diff --git a/examples/data-objects/client-ui-lib/src/controls/commandBox.tsx b/examples/data-objects/client-ui-lib/src/controls/commandBox.tsx index 5675ea1ac8df..4e0cfa1fa86d 100644 --- a/examples/data-objects/client-ui-lib/src/controls/commandBox.tsx +++ b/examples/data-objects/client-ui-lib/src/controls/commandBox.tsx @@ -51,7 +51,7 @@ export const CommandBox: React.FC = (props: ICommandBoxProps) inputEl.focus(); return () => { inputEl.removeEventListener("input", filterCommands); - } + }; } }); diff --git a/examples/data-objects/client-ui-lib/src/controls/flowView.ts b/examples/data-objects/client-ui-lib/src/controls/flowView.ts index 55f7e6dde9f0..5cff5869abf8 100644 --- a/examples/data-objects/client-ui-lib/src/controls/flowView.ts +++ b/examples/data-objects/client-ui-lib/src/controls/flowView.ts @@ -799,13 +799,13 @@ function lineIntersectsRect(y: number, rect: IExcludedRectangle) { class Viewport { // Keep the line divs in order - private lineDivs: ILineDiv[] = []; + private readonly lineDivs: ILineDiv[] = []; private lineTop = 0; private excludedRects = []; private lineX = 0; private readonly inclusions: Map = new Map(); - constructor(private maxHeight: number, public div: IViewportDiv, private width: number) { + constructor(private readonly maxHeight: number, public div: IViewportDiv, private readonly width: number) { } // Remove inclusions that are not in the excluded rect list diff --git a/examples/data-objects/codemirror/package.json b/examples/data-objects/codemirror/package.json index 53cf0ca88fbf..308a23c1e418 100644 --- a/examples/data-objects/codemirror/package.json +++ b/examples/data-objects/codemirror/package.json @@ -56,7 +56,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", "@typescript-eslint/eslint-plugin": "~5.9.0", diff --git a/examples/data-objects/codemirror/src/index.ts b/examples/data-objects/codemirror/src/index.ts index e528cf04bf47..c147cec26709 100644 --- a/examples/data-objects/codemirror/src/index.ts +++ b/examples/data-objects/codemirror/src/index.ts @@ -7,7 +7,7 @@ import { IContainerContext } from "@fluidframework/container-definitions"; import { ContainerRuntime } from "@fluidframework/container-runtime"; import { IContainerRuntime } from "@fluidframework/container-runtime-definitions"; import { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions"; -import { buildRuntimeRequestHandler, RuntimeRequestHandler } from "@fluidframework/request-handler"; +import { buildRuntimeRequestHandler } from "@fluidframework/request-handler"; import { mountableViewRequestHandler } from "@fluidframework/aqueduct"; import { requestFluidObject, @@ -35,25 +35,22 @@ const defaultComponentId = "default"; const smde = new SmdeFactory(); -type ViewCallback = (fluidModel: T) => any; - -const makeViewRequestHandler = (viewCallback: ViewCallback): RuntimeRequestHandler => - async (request: RequestParser, runtime: IContainerRuntime) => { - if (request.pathParts.length === 0) { - const objectRequest = RequestParser.create({ - url: ``, - headers: request.headers, - }); - const fluidObject = await requestFluidObject( - await runtime.getRootDataStore(defaultComponentId), - objectRequest); - const viewResponse = viewCallback(fluidObject); - return { status: 200, mimeType: "fluid/view", value: viewResponse }; - } - }; - -const viewCallback = - (codeMirror: CodeMirrorComponent) => new CodeMirrorView(codeMirror.text, codeMirror.presenceManager); +const viewRequestHandler = async (request: RequestParser, runtime: IContainerRuntime) => { + if (request.pathParts.length === 0) { + const objectRequest = RequestParser.create({ + url: ``, + headers: request.headers, + }); + const codeMirror = await requestFluidObject( + await runtime.getRootDataStore(defaultComponentId), + objectRequest); + return { + status: 200, + mimeType: "fluid/view", + value: new CodeMirrorView(codeMirror.text, codeMirror.presenceManager), + }; + } +}; class CodeMirrorFactory extends RuntimeFactoryHelper { public async instantiateFirstTime(runtime: ContainerRuntime): Promise { @@ -72,7 +69,7 @@ class CodeMirrorFactory extends RuntimeFactoryHelper { context, registry, buildRuntimeRequestHandler( - mountableViewRequestHandler(MountableView, [makeViewRequestHandler(viewCallback)]), + mountableViewRequestHandler(MountableView, [viewRequestHandler]), ), undefined, // runtimeOptions undefined, // containerScope diff --git a/examples/data-objects/diceroller/package.json b/examples/data-objects/diceroller/package.json index 171ef4fa752e..d18e24d4d4b8 100644 --- a/examples/data-objects/diceroller/package.json +++ b/examples/data-objects/diceroller/package.json @@ -47,7 +47,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/data-objects/focus-tracker/package.json b/examples/data-objects/focus-tracker/package.json index 2027d97c0a8d..28c3fc94444b 100644 --- a/examples/data-objects/focus-tracker/package.json +++ b/examples/data-objects/focus-tracker/package.json @@ -40,7 +40,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/data-objects/image-gallery/package.json b/examples/data-objects/image-gallery/package.json index 7b8a357e0262..303a2de368ec 100644 --- a/examples/data-objects/image-gallery/package.json +++ b/examples/data-objects/image-gallery/package.json @@ -43,7 +43,7 @@ }, "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", "@types/react": "^16.9.15", diff --git a/examples/data-objects/key-value-cache/package.json b/examples/data-objects/key-value-cache/package.json index 4689e62e5c0a..de05d6497523 100644 --- a/examples/data-objects/key-value-cache/package.json +++ b/examples/data-objects/key-value-cache/package.json @@ -48,7 +48,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", "@typescript-eslint/eslint-plugin": "~5.9.0", diff --git a/examples/data-objects/monaco/package.json b/examples/data-objects/monaco/package.json index a655581fa42b..5cc2132cd149 100644 --- a/examples/data-objects/monaco/package.json +++ b/examples/data-objects/monaco/package.json @@ -49,7 +49,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@typescript-eslint/eslint-plugin": "~5.9.0", "@typescript-eslint/parser": "~5.9.0", diff --git a/examples/data-objects/multiview/constellation-model/package.json b/examples/data-objects/multiview/constellation-model/package.json index a6d230519279..9769d1b52045 100644 --- a/examples/data-objects/multiview/constellation-model/package.json +++ b/examples/data-objects/multiview/constellation-model/package.json @@ -46,7 +46,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/data-objects/multiview/constellation-view/package.json b/examples/data-objects/multiview/constellation-view/package.json index 155899bb82a7..044c92252949 100644 --- a/examples/data-objects/multiview/constellation-view/package.json +++ b/examples/data-objects/multiview/constellation-view/package.json @@ -44,7 +44,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/data-objects/multiview/container/package.json b/examples/data-objects/multiview/container/package.json index 65ab06d54271..50f5b0c28592 100644 --- a/examples/data-objects/multiview/container/package.json +++ b/examples/data-objects/multiview/container/package.json @@ -55,7 +55,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/data-objects/multiview/coordinate-model/package.json b/examples/data-objects/multiview/coordinate-model/package.json index 7c91450a7943..1a91bd776347 100644 --- a/examples/data-objects/multiview/coordinate-model/package.json +++ b/examples/data-objects/multiview/coordinate-model/package.json @@ -44,7 +44,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/data-objects/multiview/interface/package.json b/examples/data-objects/multiview/interface/package.json index 71f146ab226b..10d4b1877f79 100644 --- a/examples/data-objects/multiview/interface/package.json +++ b/examples/data-objects/multiview/interface/package.json @@ -28,7 +28,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", "@types/node": "^14.18.0", diff --git a/examples/data-objects/multiview/plot-coordinate-view/package.json b/examples/data-objects/multiview/plot-coordinate-view/package.json index 5c25a685cb49..f58c335aa988 100644 --- a/examples/data-objects/multiview/plot-coordinate-view/package.json +++ b/examples/data-objects/multiview/plot-coordinate-view/package.json @@ -43,7 +43,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/data-objects/multiview/slider-coordinate-view/package.json b/examples/data-objects/multiview/slider-coordinate-view/package.json index abb37a01a81e..8a4fcca79652 100644 --- a/examples/data-objects/multiview/slider-coordinate-view/package.json +++ b/examples/data-objects/multiview/slider-coordinate-view/package.json @@ -43,7 +43,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/data-objects/multiview/triangle-view/package.json b/examples/data-objects/multiview/triangle-view/package.json index 2c2f04faad68..772d6d198de4 100644 --- a/examples/data-objects/multiview/triangle-view/package.json +++ b/examples/data-objects/multiview/triangle-view/package.json @@ -43,7 +43,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/data-objects/musica/package.json b/examples/data-objects/musica/package.json index f14e211a2003..abcce663bb5d 100644 --- a/examples/data-objects/musica/package.json +++ b/examples/data-objects/musica/package.json @@ -47,7 +47,7 @@ "@babel/plugin-proposal-class-properties": "^7.4.4", "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/babel__core": "^7", "@types/node": "^14.18.0", diff --git a/examples/data-objects/pond/package.json b/examples/data-objects/pond/package.json index 5e7e705d56b1..f976e348416c 100644 --- a/examples/data-objects/pond/package.json +++ b/examples/data-objects/pond/package.json @@ -53,7 +53,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@fluidframework/test-utils": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", diff --git a/examples/data-objects/primitives/package.json b/examples/data-objects/primitives/package.json index 01fa550b6ff7..2a2639d639f0 100644 --- a/examples/data-objects/primitives/package.json +++ b/examples/data-objects/primitives/package.json @@ -44,7 +44,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", "@types/react": "^16.9.15", diff --git a/examples/data-objects/prosemirror/package.json b/examples/data-objects/prosemirror/package.json index 89c2a03ebc9b..b82b6a16efb9 100644 --- a/examples/data-objects/prosemirror/package.json +++ b/examples/data-objects/prosemirror/package.json @@ -69,7 +69,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", "@types/orderedmap": "^1", diff --git a/examples/data-objects/prosemirror/src/index.ts b/examples/data-objects/prosemirror/src/index.ts index 5b314776726e..17d74ff43631 100644 --- a/examples/data-objects/prosemirror/src/index.ts +++ b/examples/data-objects/prosemirror/src/index.ts @@ -7,7 +7,7 @@ import { mountableViewRequestHandler } from "@fluidframework/aqueduct"; import { IContainerContext } from "@fluidframework/container-definitions"; import { ContainerRuntime } from "@fluidframework/container-runtime"; import { IContainerRuntime } from "@fluidframework/container-runtime-definitions"; -import { buildRuntimeRequestHandler, RuntimeRequestHandler } from "@fluidframework/request-handler"; +import { buildRuntimeRequestHandler } from "@fluidframework/request-handler"; import { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions"; import { requestFluidObject, RequestParser, RuntimeFactoryHelper } from "@fluidframework/runtime-utils"; import { MountableView } from "@fluidframework/view-adapters"; @@ -17,24 +17,18 @@ export { ProseMirror, ProseMirrorFactory, ProseMirrorView } from "./prosemirror" const defaultComponentId = "default"; -type ViewCallback = (fluidModel: T) => any; - -const makeViewRequestHandler = (viewCallback: ViewCallback): RuntimeRequestHandler => - async (request: RequestParser, runtime: IContainerRuntime) => { - if (request.pathParts.length === 0) { - const objectRequest = RequestParser.create({ - url: ``, - headers: request.headers, - }); - const fluidObject = await requestFluidObject( - await runtime.getRootDataStore(defaultComponentId), - objectRequest); - const viewResponse = viewCallback(fluidObject); - return { status: 200, mimeType: "fluid/view", value: viewResponse }; - } - }; - -const viewCallback = (proseMirror: ProseMirror) => new ProseMirrorView(proseMirror.collabManager); +const viewRequestHandler = async (request: RequestParser, runtime: IContainerRuntime) => { + if (request.pathParts.length === 0) { + const objectRequest = RequestParser.create({ + url: ``, + headers: request.headers, + }); + const proseMirror = await requestFluidObject( + await runtime.getRootDataStore(defaultComponentId), + objectRequest); + return { status: 200, mimeType: "fluid/view", value: new ProseMirrorView(proseMirror.collabManager) }; + } +}; class ProseMirrorRuntimeFactory extends RuntimeFactoryHelper { public async instantiateFirstTime(runtime: ContainerRuntime): Promise { @@ -53,7 +47,7 @@ class ProseMirrorRuntimeFactory extends RuntimeFactoryHelper { context, registry, buildRuntimeRequestHandler( - mountableViewRequestHandler(MountableView, [makeViewRequestHandler(viewCallback)]), + mountableViewRequestHandler(MountableView, [viewRequestHandler]), ), undefined, // runtimeOptions undefined, // containerScope diff --git a/examples/data-objects/shared-text/src/dataObject.ts b/examples/data-objects/shared-text/src/dataObject.ts index 479fb0a5373d..040b30d1356c 100644 --- a/examples/data-objects/shared-text/src/dataObject.ts +++ b/examples/data-objects/shared-text/src/dataObject.ts @@ -32,9 +32,12 @@ export class SharedTextDataObject extends DataObject { return this.runtime; } - private _sharedString: SharedString; + private _sharedString: SharedString | undefined; // It's also generally not a good pattern to expose raw data structures publicly. public get sharedString(): SharedString { + if (this._sharedString === undefined) { + throw new Error("Shared string not initialized"); + } return this._sharedString; } @@ -45,7 +48,11 @@ export class SharedTextDataObject extends DataObject { } protected async hasInitialized() { - this._sharedString = await this.root.get>(textSharedStringId).get(); + const sharedStringHandle = this.root.get>(textSharedStringId); + if (sharedStringHandle === undefined) { + throw new Error("Shared string handle not found"); + } + this._sharedString = await sharedStringHandle.get(); } } diff --git a/examples/data-objects/shared-text/src/index.ts b/examples/data-objects/shared-text/src/index.ts index cca160d7b43d..6535fc8bd677 100644 --- a/examples/data-objects/shared-text/src/index.ts +++ b/examples/data-objects/shared-text/src/index.ts @@ -7,7 +7,6 @@ import { ContainerViewRuntimeFactory } from "@fluid-example/example-utils"; import { SharedTextDataObject } from "./dataObject"; import { SharedTextView } from "./view"; - const sharedTextViewCallback = (sharedTextDataObject: SharedTextDataObject) => new SharedTextView(sharedTextDataObject); export const fluidExport = new ContainerViewRuntimeFactory(SharedTextDataObject.factory, sharedTextViewCallback); diff --git a/examples/data-objects/shared-text/src/view.ts b/examples/data-objects/shared-text/src/view.ts index 16507defd0d6..d774062a6e6e 100644 --- a/examples/data-objects/shared-text/src/view.ts +++ b/examples/data-objects/shared-text/src/view.ts @@ -10,10 +10,12 @@ import { IFluidHTMLView } from "@fluidframework/view-interfaces"; import { SharedTextDataObject } from "./dataObject"; +/* eslint-disable import/no-internal-modules, import/no-unassigned-import */ import "bootstrap/dist/css/bootstrap.min.css"; import "bootstrap/dist/css/bootstrap-theme.min.css"; import "../stylesheets/map.css"; import "../stylesheets/style.css"; +/* eslint-enable import/no-internal-modules, import/no-unassigned-import */ const debug = registerDebug("fluid:shared-text"); diff --git a/examples/data-objects/shared-text/tsconfig.json b/examples/data-objects/shared-text/tsconfig.json index e81b893d036c..9cbcb1e02896 100644 --- a/examples/data-objects/shared-text/tsconfig.json +++ b/examples/data-objects/shared-text/tsconfig.json @@ -5,7 +5,6 @@ "node_modules" ], "compilerOptions": { - "strictNullChecks": false, "outDir": "dist", "jsx": "react", "types": ["react", "react-dom", "jest", "puppeteer", "jest-environment-puppeteer", "expect-puppeteer"] diff --git a/examples/data-objects/simple-fluidobject-embed/package.json b/examples/data-objects/simple-fluidobject-embed/package.json index fcce2522533a..a7760ae08aed 100644 --- a/examples/data-objects/simple-fluidobject-embed/package.json +++ b/examples/data-objects/simple-fluidobject-embed/package.json @@ -42,7 +42,7 @@ }, "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", "@types/react": "^16.9.15", diff --git a/examples/data-objects/smde/package.json b/examples/data-objects/smde/package.json index 705b23063c77..df6a3f8a5096 100644 --- a/examples/data-objects/smde/package.json +++ b/examples/data-objects/smde/package.json @@ -54,7 +54,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/marked": "^2.0.2", "@types/node": "^14.18.0", diff --git a/examples/data-objects/table-document/package.json b/examples/data-objects/table-document/package.json index 3f8f78c8403f..8da05dfef19c 100644 --- a/examples/data-objects/table-document/package.json +++ b/examples/data-objects/table-document/package.json @@ -62,7 +62,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/runtime-utils": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", diff --git a/examples/data-objects/table-view/package.json b/examples/data-objects/table-view/package.json index a4b282d0aa83..aa05fe7c7064 100644 --- a/examples/data-objects/table-view/package.json +++ b/examples/data-objects/table-view/package.json @@ -53,7 +53,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", "@typescript-eslint/eslint-plugin": "~5.9.0", diff --git a/examples/data-objects/task-selection/package.json b/examples/data-objects/task-selection/package.json index e18738aa4042..cb064d5823b4 100644 --- a/examples/data-objects/task-selection/package.json +++ b/examples/data-objects/task-selection/package.json @@ -48,7 +48,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/data-objects/todo/package.json b/examples/data-objects/todo/package.json index f4b479269d64..c0050d958a49 100644 --- a/examples/data-objects/todo/package.json +++ b/examples/data-objects/todo/package.json @@ -55,7 +55,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@fluidframework/test-utils": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", diff --git a/examples/data-objects/vltava/package.json b/examples/data-objects/vltava/package.json index 1d8d9ff9637a..113182011274 100644 --- a/examples/data-objects/vltava/package.json +++ b/examples/data-objects/vltava/package.json @@ -62,7 +62,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", diff --git a/examples/data-objects/vltava/src/index.ts b/examples/data-objects/vltava/src/index.ts index f467e5377373..67b36e3a5ccb 100644 --- a/examples/data-objects/vltava/src/index.ts +++ b/examples/data-objects/vltava/src/index.ts @@ -70,11 +70,11 @@ export class InternalRegistry implements IFluidDataStoreRegistry, IFluidObjectIn return index >= 0 && this.containerFluidObjectArray[index].capabilities.includes(capability); } - public getByFactory(factoryId: string): IInternalRegistryEntry | undefined { + public getByFactory(factoryId: string): IInternalRegistryEntry | undefined { return this.containerFluidObjectArray.find((entry) => entry.factory.type === factoryId); } - public getAll(): IInternalRegistryEntry[] { + public getAll(): IInternalRegistryEntry[] { return this.containerFluidObjectArray; } } @@ -101,7 +101,6 @@ export class VltavaRuntimeFactory extends ContainerRuntimeFactoryWithDefaultData } } - interface ISingleHandleItem { handle: IFluidHandle; } diff --git a/examples/data-objects/webflow/package.json b/examples/data-objects/webflow/package.json index 37c0c5cea81a..c7aaf1a25ad5 100644 --- a/examples/data-objects/webflow/package.json +++ b/examples/data-objects/webflow/package.json @@ -85,7 +85,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/runtime-utils": "^0.58.1000", "@fluidframework/test-utils": "^0.58.1000", diff --git a/examples/hosts/app-integration/container-views/package.json b/examples/hosts/app-integration/container-views/package.json index e228566baee0..a33b931ced24 100644 --- a/examples/hosts/app-integration/container-views/package.json +++ b/examples/hosts/app-integration/container-views/package.json @@ -48,7 +48,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/hosts/app-integration/external-controller/package.json b/examples/hosts/app-integration/external-controller/package.json index 47a3d17da522..ed3974e47921 100644 --- a/examples/hosts/app-integration/external-controller/package.json +++ b/examples/hosts/app-integration/external-controller/package.json @@ -42,7 +42,7 @@ "devDependencies": { "@fluid-experimental/get-container": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/fluid-static": "^0.58.1000", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", diff --git a/examples/hosts/app-integration/external-views/package.json b/examples/hosts/app-integration/external-views/package.json index 94e085d143ed..a8ea0759ec8a 100644 --- a/examples/hosts/app-integration/external-views/package.json +++ b/examples/hosts/app-integration/external-views/package.json @@ -41,7 +41,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/examples/hosts/host-service-interfaces/package.json b/examples/hosts/host-service-interfaces/package.json index 6448103f5365..66fc63b7abf2 100644 --- a/examples/hosts/host-service-interfaces/package.json +++ b/examples/hosts/host-service-interfaces/package.json @@ -34,7 +34,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", diff --git a/examples/hosts/hosts-sample/package.json b/examples/hosts/hosts-sample/package.json index febb08d105f2..d6b091f0cb36 100644 --- a/examples/hosts/hosts-sample/package.json +++ b/examples/hosts/hosts-sample/package.json @@ -42,7 +42,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/react": "^16.9.15", "@types/semver": "^7.3.6", diff --git a/examples/hosts/iframe-host/package.json b/examples/hosts/iframe-host/package.json index 5e8e0e8f11c3..4e133499baef 100644 --- a/examples/hosts/iframe-host/package.json +++ b/examples/hosts/iframe-host/package.json @@ -53,7 +53,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", diff --git a/examples/hosts/node-host/package.json b/examples/hosts/node-host/package.json index 0694e0c91895..cf20794156c9 100644 --- a/examples/hosts/node-host/package.json +++ b/examples/hosts/node-host/package.json @@ -37,7 +37,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@typescript-eslint/eslint-plugin": "~5.9.0", "@typescript-eslint/parser": "~5.9.0", diff --git a/examples/utils/bundle-size-tests/package.json b/examples/utils/bundle-size-tests/package.json index 6c0d4e69881b..a408c67f4147 100644 --- a/examples/utils/bundle-size-tests/package.json +++ b/examples/utils/bundle-size-tests/package.json @@ -35,7 +35,7 @@ "devDependencies": { "@fluidframework/build-common": "^0.23.0", "@fluidframework/bundle-size-tools": "^0.0.8505", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@mixer/webpack-bundle-compare": "^0.1.0", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", diff --git a/examples/utils/example-utils/package.json b/examples/utils/example-utils/package.json index bd4e52d8f268..4085ded0a6ad 100644 --- a/examples/utils/example-utils/package.json +++ b/examples/utils/example-utils/package.json @@ -37,7 +37,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@typescript-eslint/eslint-plugin": "~5.9.0", diff --git a/experimental/PropertyDDS/packages/property-changeset/.eslintrc.js b/experimental/PropertyDDS/packages/property-changeset/.eslintrc.js index 2201ba285329..0992b1d3d1f5 100644 --- a/experimental/PropertyDDS/packages/property-changeset/.eslintrc.js +++ b/experimental/PropertyDDS/packages/property-changeset/.eslintrc.js @@ -11,15 +11,41 @@ module.exports = { "project": ["./tsconfig.json", "./src/test/tsconfig.json"] }, "rules": { + "@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/ban-types": "off", + "@typescript-eslint/consistent-type-definitions": "off", "@typescript-eslint/dot-notation": "off", + "@typescript-eslint/no-dynamic-delete": "off", + "@typescript-eslint/no-empty-interface": "off", "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/no-require-imports": "off", + "@typescript-eslint/no-shadow": "off", + "@typescript-eslint/no-this-alias": "off", + "@typescript-eslint/no-unnecessary-qualifier": "off", "@typescript-eslint/no-unnecessary-type-assertion": "off", + "@typescript-eslint/no-unsafe-return": "off", + "@typescript-eslint/no-unused-expressions": "off", + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/prefer-for-of": "off", + "@typescript-eslint/quotes": "off", + "@typescript-eslint/restrict-plus-operands": "off", + "@typescript-eslint/strict-boolean-expressions": "off", + "@typescript-eslint/unified-signatures": "off", "eqeqeq": "off", + "import/no-internal-modules": "off", "max-len": "off", + "no-case-declarations": "off", + "no-inner-declarations": "off", "no-multi-spaces": "off", + "no-param-reassign": "off", + "no-prototype-builtins": "off", + "no-restricted-syntax": "off", + "no-useless-escape": "off", "no-var": "off", + "prefer-arrow-callback": "off", "prefer-const": "off", + "prefer-template": "off", + "quote-props": "off", "unicorn/better-regex": "off", "unicorn/filename-case": "off" } diff --git a/experimental/PropertyDDS/packages/property-changeset/src/changeset.ts b/experimental/PropertyDDS/packages/property-changeset/src/changeset.ts index 83846212acd2..cbad15df61fa 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/changeset.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/changeset.ts @@ -13,27 +13,26 @@ import isEmpty from "lodash/isEmpty"; import extend from "lodash/extend"; import each from "lodash/each"; -//@ts-ignore +// @ts-ignore import { ConsoleUtils, joinPaths, constants } from "@fluid-experimental/property-common"; import { TypeIdHelper } from "./helpers/typeidHelper"; import { ChangeSetArrayFunctions } from './changeset_operations/array'; import { ArrayChangeSetIterator } from "./changeset_operations/arrayChangesetIterator"; -import { ConflictType } from './changeset_operations/changesetConflictTypes' +import { ConflictType } from './changeset_operations/changesetConflictTypes'; // Add the indexed collection functions into the prototype of the ChangeSet import { ChangeSetIndexedCollectionFunctions } from "./changeset_operations/indexedCollection"; import { isEmptyChangeSet } from "./changeset_operations/isEmptyChangeset"; import { isReservedKeyword } from "./isReservedKeyword"; import { Utils } from "./utils"; import { TemplateValidator } from "./templateValidator"; -import { ArrayIteratorOperationTypes } from "./changeset_operations/operationTypes" +import { ArrayIteratorOperationTypes } from "./changeset_operations/operationTypes"; const { PROPERTY_PATH_DELIMITER, MSG } = constants; const { extractContext, isPrimitiveType } = TypeIdHelper; - export interface ApplyChangeSetOptions { /** * Additional meta information which help later to obtain more compact changeset during the apply operation. @@ -46,7 +45,6 @@ export interface ApplyChangeSetOptions { throwOnTemplateMismatch?: boolean } - export interface RebaseChangeSetOptions extends ApplyChangeSetOptions { rebaseMetaInformation?: object } @@ -54,7 +52,7 @@ export interface RebaseChangeSetOptions extends ApplyChangeSetOptions { /** * The plain serialization data structure used to encode a ChangeSet. */ -export type SerializedChangeSet = any; //@TODO Maybe we should add full type for the ChangeSet +export type SerializedChangeSet = any; // @TODO Maybe we should add full type for the ChangeSet export type ChangeSetType = any; export interface ConflictInfo { /** @@ -86,7 +84,6 @@ export class ChangeSet { declare public _performApplyAfterOnPropertyIndexedCollection: typeof ChangeSetIndexedCollectionFunctions._performApplyAfterOnPropertyIndexedCollection; declare public _rebaseIndexedCollectionChangeSetForProperty: typeof ChangeSetIndexedCollectionFunctions._rebaseIndexedCollectionChangeSetForProperty; - _changes: SerializedChangeSet; _isNormalized: boolean; @@ -109,15 +106,13 @@ export class ChangeSet { this._isNormalized = false; } - /** * Creates a string representation of the change set * @returns JSON encoding of the changes in this change set */ toString(): string { return JSON.stringify(this._changes); - }; - + } /** * Returns the serialized changes. @@ -126,7 +121,7 @@ export class ChangeSet { */ getSerializedChangeSet(): SerializedChangeSet { return this._changes; - }; + } /** * Indicates whether this is a normalized ChangeSet. If this is set to true, squashes will not remove empty entries @@ -136,7 +131,7 @@ export class ChangeSet { */ setIsNormalized(in_isNormalized: boolean) { this._isNormalized = in_isNormalized; - }; + } /** * Indicates whether this is a normalized ChangeSet. If this is set to true, squashes will not remove empty entries @@ -146,7 +141,7 @@ export class ChangeSet { */ getIsNormalized(): boolean { return this._isNormalized; - }; + } /** * Clones the ChangeSet @@ -155,8 +150,7 @@ export class ChangeSet { */ clone(): ChangeSet { return new ChangeSet(cloneDeep(this._changes)); - }; - + } /** * Updates this ChangeSet. The result will be the concatenation of the two ChangeSets. First the changes in this @@ -179,7 +173,7 @@ export class ChangeSet { } else { this._performApplyAfterOnProperty(this._changes, changes, !this._isNormalized, in_options); } - }; + } /** * Applies a changeset to a given property (recursively). The ChangeSet is assumed to be relative to the same @@ -236,7 +230,7 @@ export class ChangeSet { delete io_basePropertyChanges[typeid]; } } - }; + } /** * Helper function used to apply a new value to a given ChangeSet. @@ -263,7 +257,7 @@ export class ChangeSet { io_baseChanges[in_baseKey] = newValue; } } - }; + } /** * Decides based on the given Typeid which applyAfter operation to perform. @@ -398,7 +392,7 @@ export class ChangeSet { } else { throw new Error(MSG.UNKNOWN_CONTEXT + splitTypeid.context); } - }; + } /** * Rebases a given ChangeSet behind the current ChangeSet. @@ -418,7 +412,7 @@ export class ChangeSet { in_options?: RebaseChangeSetOptions): SerializedChangeSet { // We actually only pass this request to the recursive internal function return this._rebaseChangeSetForProperty(this._changes, io_changeSet, "", out_conflicts, in_options); - }; + } /** * Internal helper function that performs a rebase on a single property @@ -599,7 +593,7 @@ export class ChangeSet { } return io_rebasePropertyChangeSet; - }; + } /** * Decides based on the given Typeid which rebase operation to perform @@ -691,7 +685,7 @@ export class ChangeSet { } return false; - }; + } /** * recursive helper function for ChangeSet.prototype._toReversibleChangeSet @@ -891,7 +885,7 @@ export class ChangeSet { } } } - }; + } /** * Converts an irreversible changeset to a reversible changeset @@ -922,7 +916,7 @@ export class ChangeSet { userData: workspace, }); } - }; + } /** * Converts a reversible changeset to an irreversible changeset @@ -1044,7 +1038,7 @@ export class ChangeSet { Utils.traverseChangeSetRecursively(this._changes, { preCallback: callback, }); - }; + } /** * Helper function to extract the first level paths from a given change set @@ -1067,7 +1061,7 @@ export class ChangeSet { } return paths; - }; + } /** * recursive helper function for ChangeSet.prototype._toInverseChangeSet @@ -1203,7 +1197,7 @@ export class ChangeSet { } } } - }; + } /** * Inverts a reversible ChangeSets @@ -1225,7 +1219,6 @@ export class ChangeSet { } } - ChangeSet.prototype._performApplyAfterOnPropertyArray = ChangeSetArrayFunctions._performApplyAfterOnPropertyArray; ChangeSet.prototype._rebaseArrayChangeSetForProperty = ChangeSetArrayFunctions._rebaseArrayChangeSetForProperty; ChangeSet.prototype._rebaseChangeSetForString = ChangeSetArrayFunctions._rebaseChangeSetForString; diff --git a/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/array.ts b/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/array.ts index 7da9f10dafa1..df895a89a4aa 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/array.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/array.ts @@ -20,7 +20,6 @@ import { ConflictType } from "./changesetConflictTypes"; const { MSG } = constants; const { isPrimitiveType } = TypeIdHelper; - /** * The range combinations of two change sets (A and B) * This can either be complete operations, parts of complete operations or overlapping segments @@ -35,8 +34,7 @@ enum ArrayChangeSetRangeType { completeBpartOfA, // a complete operation of change set B overlapping with a partial operation of change set A completeAcompleteB, // a complete operation of change set A overlapping a complete operation of change set B partOfApartOfB, // a partial operation of change set A, a partial operation of change set B -}; - +} interface SegmentType { begin?: number; @@ -96,7 +94,6 @@ export interface OperationRangeModify extends Omit, 'removeInsertOperationB' | 'removeInsertOperation' | 'removeInsertOperationA'> { } - /** * A range of a none NOP array operation */ @@ -166,7 +163,7 @@ const getRangeForAppliedOperation = function( in_operation: GenericOperation, io_resultingRange: OperationRangeDescription, in_flag?: ArrayChangeSetRangeType, - in_options?: ApplyChangeSetOptions + in_options?: ApplyChangeSetOptions, ) { if (!in_operation || in_operation.type === ArrayChangeSetIterator.types.NOP) { io_resultingRange.begin = undefined; @@ -185,7 +182,6 @@ const getRangeForAppliedOperation = function( } io_resultingRange.op.operation[0] = in_operation.operation[0]; - io_resultingRange.begin = in_operation.operation[0]; io_resultingRange.op._absoluteBegin = in_operation.operation[0]; if (in_flag !== undefined) { @@ -242,7 +238,7 @@ const _splitArrayParameter = function( in_firstResult: arrayModifyList | arrayRemoveList, in_secondResult: arrayModifyList | arrayRemoveList, in_data: arrayModifyList | arrayRemoveList, - in_start: number + in_start: number, ) { let firstTmp: any; if (isString(in_data[1])) { @@ -291,7 +287,7 @@ const _splitOperation = function( in_targetRange: OperationRangeDescription, in_targetOperation: NoneNOPOperation, lengthUsedInResultSegment: number, - in_updateOffset: boolean + in_updateOffset: boolean, ) { _splitArrayParameter(in_targetOperation.operation, in_targetRange.op.operation, in_targetRange.op.operation, lengthUsedInResultSegment); @@ -1337,7 +1333,6 @@ export namespace ChangeSetArrayFunctions { ConsoleUtils.assert(!isString(io_basePropertyChanges), io_basePropertyChanges); ConsoleUtils.assert(!isString(in_appliedPropertyChanges), in_appliedPropertyChanges); - const isPrimitiveTypeid = isPrimitiveType(in_typeid); // Iterator to process the changes in the ChangeSet in the correct order @@ -1353,7 +1348,6 @@ export namespace ChangeSetArrayFunctions { getRangeForCurrentStateOperation(opA, opA.offset ? opA.offset : 0, rangeA); getRangeForAppliedOperation(opB, rangeB, undefined, in_options); - const resultPropertyChanges: SerializedChangeSet = {}; resultPropertyChanges.insert = []; resultPropertyChanges.modify = []; @@ -1500,7 +1494,7 @@ export namespace ChangeSetArrayFunctions { } else { delete io_basePropertyChanges.remove; } - }; + } /** * Performs the rebase operation for array changes @@ -1707,4 +1701,4 @@ export namespace ChangeSetArrayFunctions { in_options); } } -}; +} diff --git a/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/arrayChangesetIterator.ts b/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/arrayChangesetIterator.ts index cf62f7ab0713..565f4a8ed7ee 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/arrayChangesetIterator.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/arrayChangesetIterator.ts @@ -6,7 +6,6 @@ * @fileoverview Iterator to iterate over array ChangeSets */ - import isNumber from "lodash/isNumber"; import isString from "lodash/isString"; @@ -16,17 +15,12 @@ import { constants } from "@fluid-experimental/property-common"; import { SerializedChangeSet } from "../changeset"; import { ArrayIteratorOperationTypes } from "./operationTypes"; - const { MSG } = constants; - - -type genericArray = Array; -export type arrayInsertList = [number, string | genericArray] -export type arrayModifyList = [number, string | genericArray] | [number, string, string] | [number, genericArray, genericArray] -export type arrayRemoveList = [number, number | string | genericArray] - - +type genericArray = (number | string | (SerializedChangeSet & {typeid: string}))[]; +export type arrayInsertList = [number, string | genericArray]; +export type arrayModifyList = [number, string | genericArray] | [number, string, string] | [number, genericArray, genericArray]; +export type arrayRemoveList = [number, number | string | genericArray]; /** * Description of an array operation @@ -46,7 +40,6 @@ export interface InsertOperation extends OperationDescription { operation?: arrayInsertList; } - /** * Description of a remove array operation */ @@ -68,7 +61,7 @@ export interface ModifyOperation extends OperationDescription { /** * Description of a modify array operation */ - export interface NOPOperation extends Omit { + export interface NOPOperation extends Omit { type: ArrayIteratorOperationTypes.NOP; operation?: []; } @@ -85,9 +78,9 @@ export type GenericOperation = NoneNOPOperation | NOPOperation; export class ArrayChangeSetIterator { static types = ArrayIteratorOperationTypes; // @TODO Not sure if this is still required if we export it separately. - private _changeSet: SerializedChangeSet; + private readonly _changeSet: SerializedChangeSet; private _copiedModifies: string | any[]; - private _currentIndices: { insert: number; remove: number; modify: number; }; + private readonly _currentIndices: { insert: number; remove: number; modify: number; }; private _currentOffset: number; private _lastOperationIndex: number; private _lastOperationOffset: number; @@ -133,7 +126,7 @@ export class ArrayChangeSetIterator { this._op = { type: ArrayIteratorOperationTypes.NOP, offset: 0, - operation: undefined + operation: undefined, }; // go to the first element @@ -272,14 +265,14 @@ export class ArrayChangeSetIterator { } this._atEnd = false; return true; - }; + } /** * @returns true, if there are no more operations left */ atEnd(): boolean { return this._atEnd; - }; + } private _copyModifies(in_modifies: string[]) { if (!in_modifies || in_modifies.length === 0) { @@ -290,5 +283,5 @@ export class ArrayChangeSetIterator { result.push([in_modifies[i][0], in_modifies[i][1].slice()]); } return result; - }; -}; + } +} diff --git a/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/changesetConflictTypes.ts b/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/changesetConflictTypes.ts index 4b0a80d29ba1..26edc1dbfb5a 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/changesetConflictTypes.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/changesetConflictTypes.ts @@ -8,7 +8,7 @@ export enum ConflictType { /** We had two incompatible ChangeSets, they probably were with respect to different base commits */ - INVALID_CHANGESET_BASE=1, + INVALID_CHANGESET_BASE = 1, /** A value was changed in both ChangeSets */ COLLIDING_SET, /** A deleted child node was modified */ @@ -27,6 +27,4 @@ export enum ConflictType { MISMATCH_TEMPLATES, // Tried to insert inside a removed array range INSERT_IN_REMOVED_RANGE, -}; - - +} diff --git a/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/indexedCollection.ts b/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/indexedCollection.ts index 9cbfb54c71d2..99a43e388ba7 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/indexedCollection.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/indexedCollection.ts @@ -13,7 +13,7 @@ import without from "lodash/without"; import includes from "lodash/includes"; -//@ts-ignore +// @ts-ignore import { constants, joinPaths } from "@fluid-experimental/property-common"; import { ApplyChangeSetOptions, ConflictInfo, SerializedChangeSet } from "../changeset"; import { TypeIdHelper } from "../helpers/typeidHelper"; @@ -199,7 +199,7 @@ export namespace ChangeSetIndexedCollectionFunctions { } } } - }; + } // Apply insert operations if (in_appliedPropertyChanges.insert) { @@ -392,7 +392,7 @@ export namespace ChangeSetIndexedCollectionFunctions { // Remove unnecessary entries from the ChangeSet this._cleanIndexedCollectionChangeSet(io_basePropertyChanges, !isPrimitiveTypeid); - } + }; /** * Performs the rebase operation for set and map collections @@ -462,7 +462,7 @@ export namespace ChangeSetIndexedCollectionFunctions { }; // Helper function which adds the Changes for a ChangeSet that is ordered by typeid - const addChangesWithTypeids = function (in_collection, in_changeIdentifier, in_changePrefix) { + const addChangesWithTypeids = function(in_collection, in_changeIdentifier, in_changePrefix) { if (in_collection === undefined) { return; } @@ -753,7 +753,7 @@ export namespace ChangeSetIndexedCollectionFunctions { // Remove unnecessary entries from the ChangeSet this._cleanIndexedCollectionChangeSet(io_rebasePropertyChangeSet, !isPrimitiveTypeid); - } + }; /** * Removes empty entries from the .children collection of the ChangeSet @@ -818,5 +818,5 @@ export namespace ChangeSetIndexedCollectionFunctions { if (_fastIsEmptyObject(changes.modify)) { delete changes.modify; } - } -}; + }; +} diff --git a/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/isEmptyChangeset.ts b/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/isEmptyChangeset.ts index 1f8a3bfbdb8e..c5a88833ff2b 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/isEmptyChangeset.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/isEmptyChangeset.ts @@ -21,4 +21,3 @@ export const isEmptyChangeSet = (in_changeSet: SerializedChangeSet): boolean => in_changeSet === undefined || (isObject(in_changeSet) && (isEmpty(in_changeSet) || (Object.keys(in_changeSet).length === 1 && has(in_changeSet, "typeid")))); - diff --git a/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/operationTypes.ts b/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/operationTypes.ts index f0a118ce67c9..c273d7309e71 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/operationTypes.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/changeset_operations/operationTypes.ts @@ -12,5 +12,5 @@ export enum ArrayIteratorOperationTypes { REMOVE, MODIFY, // MOVE, // reserved, not implemented yet - NOP -}; + NOP, +} diff --git a/experimental/PropertyDDS/packages/property-changeset/src/helpers/typeidHelper.ts b/experimental/PropertyDDS/packages/property-changeset/src/helpers/typeidHelper.ts index f7accacab4f4..1b2d8d8fd1be 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/helpers/typeidHelper.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/helpers/typeidHelper.ts @@ -6,9 +6,9 @@ * @fileoverview Helper functions to work with typeid strings */ -import { TemplateSchema as templateSchemaJson, NativeTypes } from "../templateSchema"; // @ts-ignore import { constants } from "@fluid-experimental/property-common"; +import { TemplateSchema as templateSchemaJson, NativeTypes } from "../templateSchema"; const { MSG } = constants; @@ -81,7 +81,7 @@ export namespace TypeIdHelper { return { version: splitTypeId[1], - typeidWithoutVersion: splitTypeId[0] + typeidWithoutVersion: splitTypeId[0], }; } @@ -123,13 +123,13 @@ export namespace TypeIdHelper { return { typeid, context, - isEnum + isEnum, }; } else { return { typeid: in_typeid, context: "single", - isEnum: false + isEnum: false, }; } } @@ -168,7 +168,7 @@ export namespace TypeIdHelper { * @param in_typeid - The typeid to check * @returns Is this a reference property typeid? */ - export function isReferenceTypeId(in_typeid: string | undefined ): boolean { // in_enum + export function isReferenceTypeId(in_typeid: string | undefined): boolean { // in_enum return in_typeid === "Reference" || (in_typeid.substr(0, 10) === "Reference<" && in_typeid.substr(-1) === ">"); } @@ -215,7 +215,6 @@ export namespace TypeIdHelper { } } - /** * Check wether the in_typeid inherits from the in_baseTypeid * @@ -283,4 +282,4 @@ export namespace TypeIdHelper { export function getReservedTypeIds(): string[] { return templateSchemaJson["$defs"]["reserved-typeid"]["enum"]; } -}; +} diff --git a/experimental/PropertyDDS/packages/property-changeset/src/index.ts b/experimental/PropertyDDS/packages/property-changeset/src/index.ts index 1d8318a86127..57946922ef43 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/index.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/index.ts @@ -24,5 +24,5 @@ export { rebaseToRemoteChanges, SerializedChangeSet, TraversalContext, - ExtractedContext + ExtractedContext, }; diff --git a/experimental/PropertyDDS/packages/property-changeset/src/pathHelper.ts b/experimental/PropertyDDS/packages/property-changeset/src/pathHelper.ts index 604c2f21face..5de2b7a38c6f 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/pathHelper.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/pathHelper.ts @@ -11,7 +11,7 @@ import { constants } from '@fluid-experimental/property-common'; const { PROPERTY_PATH_DELIMITER, MSG } = constants; -export type PathTree = Map +export type PathTree = Map; /** * Helper functions for string processing @@ -35,7 +35,7 @@ export namespace PathHelper { DEREFERENCE_TOKEN, /** A ../ that indicates one step above the current path */ RAISE_LEVEL_TOKEN, - }; + } /** * Tokenizes a path string @@ -45,7 +45,7 @@ export namespace PathHelper { * * @returns the tokens from the path string */ - export const tokenizePathString = function(in_path: string, out_types?: TOKEN_TYPES[]): Array { // eslint-disable-line complexity + export const tokenizePathString = function(in_path: string, out_types?: TOKEN_TYPES[]): string[] { // eslint-disable-line complexity const tokens = []; let currentToken = ""; @@ -456,7 +456,7 @@ export namespace PathHelper { // The base path is fully covered by at least one path from a given list of paths. // This means a property with this path would be covered and all of its children would be covered also. FULLY_COVERED, - }; + } interface BasePathCoverage { coverageExtent: CoverageExtent, @@ -474,7 +474,7 @@ export namespace PathHelper { * @returns The coverage of the property and its children. For a coverage of * 'FULLY_COVERED', only the first matching path is returned. */ - export const getPathCoverage = function(in_basePath: string, in_paths: Array): BasePathCoverage { + export const getPathCoverage = function(in_basePath: string, in_paths: string[]): BasePathCoverage { // First, check if the base path is entirely included in one of the paths for (let i = 0; i < in_paths.length; i++) { if (in_basePath.startsWith(in_paths[i])) { diff --git a/experimental/PropertyDDS/packages/property-changeset/src/rebase.ts b/experimental/PropertyDDS/packages/property-changeset/src/rebase.ts index 80fbe12163ba..134db038d56d 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/rebase.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/rebase.ts @@ -20,7 +20,7 @@ class SyncPromise { then(fn: (arg0: any) => { value: any; }): SyncPromise { this.value = new SyncPromise(fn(this.value)).value; return this; - }; + } } const loop = (promise: Promise, fn: { (currentChange: any): any; (currentRebasedChange: any): any; }, makePromise: (arg0: any) => any) => promise.then(fn).then((result) => result === null ? result : loop(makePromise(result), fn, makePromise)); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/templateValidator.ts b/experimental/PropertyDDS/packages/property-changeset/src/templateValidator.ts index 341aeedc2dfd..423b350b88f8 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/templateValidator.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/templateValidator.ts @@ -10,7 +10,7 @@ /* eslint-disable no-use-before-define */ import Ajv from "ajv"; -import ajvKeywords from "ajv-keywords" +import ajvKeywords from "ajv-keywords"; import each from "lodash/each"; import isEqual from "lodash/isEqual"; @@ -30,7 +30,7 @@ import { gt, diff, major, valid, compare } from "semver"; import traverse from "traverse"; import { queue } from "async"; -//@ts-ignore +// @ts-ignore import { constants, ConsoleUtils } from "@fluid-experimental/property-common"; import { TemplateSchema } from "./templateSchema"; import { TypeIdHelper } from "./helpers/typeidHelper"; @@ -40,7 +40,7 @@ const { MSG } = constants; const ajvFactory = new Ajv({ allErrors: true, - verbose: true + verbose: true, }); ajvKeywords(ajvFactory, "prohibited"); @@ -48,14 +48,14 @@ ajvKeywords(ajvFactory, "typeof"); const _syntaxValidator = ajvFactory.compile(TemplateSchema); -type ValuesType = { [key: string]: ValuesType } +type ValuesType = { [key: string]: ValuesType }; type PropertyType = { id: string; context: string; typeid: string; values: ValuesType -} +}; type PropertiesType = PropertyType[]; @@ -71,7 +71,6 @@ export interface PropertySchema { type SchemaEntityType = PropertySchema | string[] | PropertiesType; - /** * A weighted enumeration of semver change types. Higher values are more important. * PATCH: Annotation and comment changes. @@ -138,7 +137,6 @@ function isPropertyArray(source: SchemaEntityType): source is PropertiesType { // return isObject(source) && !Array.isArray(source); // } - /** * An object deep compare with special handling for pset property arrays. * pset property arrays are allowed to be out of order as long as elements can be matched with @@ -571,7 +569,7 @@ const _validateSemanticAndSyntax = function(in_template: PropertySchema) { * @return {Promise} a promise that resolved to nothing * @ignore */ -const _validateSemanticAndSyntaxAsync = function(in_template: PropertySchema): Promise { +const _validateSemanticAndSyntaxAsync = async function(in_template: PropertySchema): Promise { return _validateSyntaxAsync.call(this, in_template); }; @@ -656,7 +654,7 @@ const _validateContext = function(in_template) { * @return {Promise} promise that returns without any value and rejects in case of validation error * @ignore */ -const _validateContextAsync = function(in_template) { +const _validateContextAsync = async function(in_template) { const that = this; const context = in_template.context; @@ -709,7 +707,7 @@ const _validateContextAsync = function(in_template) { } return that._inheritsFromAsync(in_template.typeid, "NamedProperty"); - }).then(function(res) { + }).then(async function(res) { if (res) { return undefined; } @@ -873,7 +871,7 @@ const createContextCheckAsyncQueue = function() { * @returns Promise that resolves without any result * @ignore */ -let _validateSyntaxAsync = function(in_template: PropertySchema): Promise { +let _validateSyntaxAsync = async function(in_template: PropertySchema): Promise { const that = this; return new Promise(function(resolve, reject) { @@ -946,11 +944,10 @@ export interface TemplateValidatorOptions { } const Utils = { - psetDeepEquals: function(in_source: PropertySchema, in_target: PropertySchema) { + psetDeepEquals(in_source: PropertySchema, in_target: PropertySchema) { return _psetDeepEquals.call(this, in_source, in_target).isEqual; - } -} - + }, +}; /** * @description Instantiates a new TemplateValidator. Must be provided with a set of inheritsFrom and hasSchema @@ -963,10 +960,9 @@ export class TemplateValidator { public _hasSchema: (schema: PropertySchema, typeid: string) => boolean; public _inheritsFromAsync: (source: PropertySchema, target: PropertySchema) => Promise; public _hasSchemaAsync: (schema: PropertySchema, typeid: string) => Promise; - private _allowDraft: boolean; - private _skipSemver: boolean; + private readonly _allowDraft: boolean; + private readonly _skipSemver: boolean; constructor(in_params: TemplateValidatorOptions = { skipSemver: false, allowDraft: false}) { - this._skipSemver = in_params ? !!in_params.skipSemver : false; this._allowDraft = in_params ? !!in_params.allowDraft : false; // Used by validate() @@ -1082,7 +1078,7 @@ export class TemplateValidator { } return this._resultBuilder.result; - }; + } /** * Validates that all templates conform to the following mandatory rules: @@ -1106,7 +1102,7 @@ export class TemplateValidator { * } * It's possible for 'isValid' to be true while 'warnings' contains one or more messages. */ - validateAsync(in_template: PropertySchema, in_templatePrevious?: PropertySchema): Promise { + async validateAsync(in_template: PropertySchema, in_templatePrevious?: PropertySchema): Promise { this._resultBuilder = new ValidationResultBuilder(in_template ? in_template.typeid : ""); _validateBasic.call(this, in_template); if (in_templatePrevious) { @@ -1118,7 +1114,7 @@ export class TemplateValidator { return (in_templatePrevious) ? this._validateAsyncWithPreviousSchema(in_template, in_templatePrevious) : _validateSemanticAndSyntaxAsync.call(this, in_template); - }; + } /** * Called by validateAsync if a previous schema is passed in argument @@ -1129,7 +1125,7 @@ export class TemplateValidator { * @returns promise that resolves to the validation results as an objet. See validateAsync * @ignore */ - private _validateAsyncWithPreviousSchema(in_template: PropertySchema, in_templatePrevious: PropertySchema): Promise { + private async _validateAsyncWithPreviousSchema(in_template: PropertySchema, in_templatePrevious: PropertySchema): Promise { const that = this; return _validateSemanticAndSyntaxAsync.call(that, in_template).then(() => _validateSemanticAndSyntaxAsync.call(that, in_templatePrevious)).then(function() { if (!that._resultBuilder.isValid()) { diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/array.spec.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/array.spec.ts index e55115d931d0..eba03adcfde0 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/array.spec.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/array.spec.ts @@ -12,9 +12,8 @@ import isNumber from "lodash/isNumber"; import {copy as cloneDeep} from "fastest-json-copy"; import range from "lodash/range"; - -import { ChangeSet, SerializedChangeSet } from "../changeset"; import { expect, assert } from "chai"; +import { ChangeSet, SerializedChangeSet } from "../changeset"; describe("Array Operations", function() { let guidCounter = 1; @@ -224,8 +223,8 @@ describe("Array Operations", function() { function runTestApplyingReverseAndRebasedChangesetForIndependentModifications(baseInsertPositions, rebasedInsertPositions, baseOperation = "insert", - baseCount = 1) { - + baseCount = 1, + ) { const createInserts = (positions, count) => positions.map((x) => [ x, generateNamedEntities(count), @@ -327,17 +326,17 @@ describe("Array Operations", function() { createArrayCS({ insert: [ [1, generateNamedEntities(1)], - ] + ], }), createArrayCS({ insert: [ [6, generateNamedEntities(1)], - ] + ], }), createArrayCS({ insert: [ [9, generateNamedEntities(1)], - ] + ], }), createArrayCS({ remove: [ @@ -350,12 +349,12 @@ describe("Array Operations", function() { createArrayCS({ insert: [ [insertPosition, generateNamedEntities(1)], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(10)], - ] + ], }), ); }); @@ -366,46 +365,46 @@ describe("Array Operations", function() { createArrayCS({ remove: [ [0, generateNamedEntities(3)], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(3)], - ] + ], }), ], createArrayCS({ insert: [ [0, generateNamedEntities(3)], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(10)], - ] + ], }), ); testRebaseDistributivity([ createArrayCS({ remove: [ [0, generateNamedEntities(3)], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(3)], - ] + ], }), ], createArrayCS({ insert: [ [3, generateNamedEntities(3)], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(10)], - ] + ], }), ); }); @@ -414,23 +413,23 @@ describe("Array Operations", function() { createArrayCS({ remove: [ [0, generateNamedEntities(3)], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(3)], - ] + ], }), ], createArrayCS({ insert: [ [3, generateNamedEntities(1)], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(10)], - ] + ], }), ); }); @@ -439,23 +438,23 @@ describe("Array Operations", function() { createArrayCS({ remove: [ [0, generateNamedEntities(3)], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(3)], - ] + ], }), ], createArrayCS({ remove: [ [1, generateNamedEntities(2)], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(10)], - ] + ], }), ); const arrayCS = getArrayCS(deltacS); @@ -467,33 +466,33 @@ describe("Array Operations", function() { createArrayCS({ insert: [ [2, generateNamedEntities(1)], - ] + ], }), createArrayCS({ remove: [ [0, generateNamedEntities(2)], - ] + ], }), createArrayCS({ remove: [ [1, generateNamedEntities(1)], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(2)], - ] + ], }), ], createArrayCS({ insert: [ [1, generateNamedEntities(1)], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(10)], - ] + ], }), ); }); @@ -502,33 +501,33 @@ describe("Array Operations", function() { createArrayCS({ insert: [ [4, generateNamedEntities(1)], - ] + ], }), createArrayCS({ remove: [ [2, generateNamedEntities(2)], - ] + ], }), createArrayCS({ remove: [ [3, generateNamedEntities(1)], - ] + ], }), createArrayCS({ insert: [ [2, generateNamedEntities(2)], - ] + ], }), ], createArrayCS({ insert: [ [3, generateNamedEntities(1)], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(10)], - ] + ], }), ); }); @@ -537,43 +536,43 @@ describe("Array Operations", function() { createArrayCS({ insert: [ [4, generateNamedEntities(1)], - ] + ], }), createArrayCS({ insert: [ [6, generateNamedEntities(1)], - ] + ], }), createArrayCS({ remove: [ [2, generateNamedEntities(2)], - ] + ], }), createArrayCS({ remove: [ [3, generateNamedEntities(1)], - ] + ], }), createArrayCS({ remove: [ [4, generateNamedEntities(1)], - ] + ], }), createArrayCS({ insert: [ [2, generateNamedEntities(2)], - ] + ], }), ], createArrayCS({ insert: [ [3, generateNamedEntities(1)], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(10)], - ] + ], }), ); }); @@ -582,23 +581,23 @@ describe("Array Operations", function() { createArrayCS({ remove: [ [1, generateNamedEntities(1)], - ] + ], }), createArrayCS({ insert: [ [1, generateNamedEntities(2)], - ] + ], }), ], createArrayCS({ remove: [ [1, generateNamedEntities(1, [3])], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(10)], - ] + ], }), ); }); @@ -607,23 +606,23 @@ describe("Array Operations", function() { createArrayCS({ remove: [ [8, generateNamedEntities(2)], - ] + ], }), createArrayCS({ insert: [ [8, generateNamedEntities(1)], - ] + ], }), ], createArrayCS({ remove: [ [8, generateNamedEntities(1, [3])], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(14)], - ] + ], }), ); }); @@ -632,7 +631,7 @@ describe("Array Operations", function() { createArrayCS({ remove: [ [8, generateNamedEntities(3)], - ] + ], }), createArrayCS({ insert: [ @@ -645,12 +644,12 @@ describe("Array Operations", function() { createArrayCS({ remove: [ [8, generateNamedEntities(1, [3])], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(14)], - ] + ], }), ); }); @@ -659,18 +658,18 @@ describe("Array Operations", function() { createArrayCS({ remove: [ [4, generateNamedEntities(1)], - ] + ], }), ], createArrayCS({ remove: [ [3, generateNamedEntities(3)], - ] + ], }), createArrayCS({ insert: [ [0, generateNamedEntities(14)], - ] + ], }), ); }); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/pathHelper.spec.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/pathHelper.spec.ts index 1c9383f269c4..c9b58b8f7f73 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/pathHelper.spec.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/pathHelper.spec.ts @@ -2,7 +2,7 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /** * @fileoverview In this file, we will test the path helper * functions described in /src/properties/path_helper.js @@ -12,7 +12,6 @@ import { expect } from 'chai'; import { PathHelper } from "../pathHelper"; describe('PathHelper', function() { - describe('tokenizePathString', function() { it('should work for simple paths separated by dots', function() { let types = []; @@ -25,7 +24,7 @@ describe('PathHelper', function() { expect(PathHelper.tokenizePathString('test.test2', types)).to.deep.equal(['test', 'test2']); expect(types).to.deep.equal([ PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, - PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN + PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, ]); expect(function() { PathHelper.tokenizePathString('.test2'); }).to.throw(); @@ -62,7 +61,7 @@ describe('PathHelper', function() { PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, PathHelper.TOKEN_TYPES.ARRAY_TOKEN, PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, - PathHelper.TOKEN_TYPES.ARRAY_TOKEN + PathHelper.TOKEN_TYPES.ARRAY_TOKEN, ]); expect(function() { PathHelper.tokenizePathString('[test]parameter'); }).to.throw(); @@ -84,17 +83,17 @@ describe('PathHelper', function() { expect(PathHelper.tokenizePathString('"test1".test2', types)).to.deep.equal(['test1', 'test2']); expect(types).to.deep.equal([ - PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN + PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, ]); expect(PathHelper.tokenizePathString('"test1"."test2"', types)).to.deep.equal(['test1', 'test2']); expect(types).to.deep.equal([ - PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN + PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, ]); expect(PathHelper.tokenizePathString('test1."test2"', types)).to.deep.equal(['test1', 'test2']); expect(types).to.deep.equal([ - PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN + PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, ]); expect(PathHelper.tokenizePathString('test1["test2"]', types)).to.deep.equal(['test1', 'test2']); @@ -123,12 +122,12 @@ describe('PathHelper', function() { expect(PathHelper.tokenizePathString('test*', types)).to.deep.equal(['test', '*']); expect(types).to.deep.equal([ - PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, PathHelper.TOKEN_TYPES.DEREFERENCE_TOKEN + PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, PathHelper.TOKEN_TYPES.DEREFERENCE_TOKEN, ]); expect(PathHelper.tokenizePathString('*.test', types)).to.deep.equal(['*', 'test']); expect(types).to.deep.equal([ - PathHelper.TOKEN_TYPES.DEREFERENCE_TOKEN, PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN + PathHelper.TOKEN_TYPES.DEREFERENCE_TOKEN, PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, ]); expect(function() { PathHelper.tokenizePathString('*test', types); }).to.throw(); @@ -140,7 +139,7 @@ describe('PathHelper', function() { PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, PathHelper.TOKEN_TYPES.DEREFERENCE_TOKEN, PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, - PathHelper.TOKEN_TYPES.DEREFERENCE_TOKEN + PathHelper.TOKEN_TYPES.DEREFERENCE_TOKEN, ]); expect(PathHelper.tokenizePathString('/*', types)).to.deep.equal(['/', '*']); @@ -156,14 +155,14 @@ describe('PathHelper', function() { expect(types).to.deep.equal([ PathHelper.TOKEN_TYPES.ARRAY_TOKEN, PathHelper.TOKEN_TYPES.DEREFERENCE_TOKEN, - PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN + PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, ]); expect(PathHelper.tokenizePathString('[test]*[test2]', types)).to.deep.equal(['test', '*', 'test2']); expect(types).to.deep.equal([ PathHelper.TOKEN_TYPES.ARRAY_TOKEN, PathHelper.TOKEN_TYPES.DEREFERENCE_TOKEN, - PathHelper.TOKEN_TYPES.ARRAY_TOKEN + PathHelper.TOKEN_TYPES.ARRAY_TOKEN, ]); expect(function() { PathHelper.tokenizePathString('[test]*test', types); }).to.throw(); @@ -178,23 +177,22 @@ describe('PathHelper', function() { let types = []; expect(PathHelper.tokenizePathString('../test', types)).to.deep.equal(['../', 'test']); expect(types).to.deep.equal([PathHelper.TOKEN_TYPES.RAISE_LEVEL_TOKEN, - PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN + PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, ]); expect(PathHelper.tokenizePathString('../../../test', types)).to.deep.equal(['../', '../', '../', 'test']); expect(types).to.deep.equal([PathHelper.TOKEN_TYPES.RAISE_LEVEL_TOKEN, PathHelper.TOKEN_TYPES.RAISE_LEVEL_TOKEN, - PathHelper.TOKEN_TYPES.RAISE_LEVEL_TOKEN, PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN + PathHelper.TOKEN_TYPES.RAISE_LEVEL_TOKEN, PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, ]); expect(PathHelper.tokenizePathString('../../test[0].test2[key]', types)).to.deep.equal( ['../', '../', 'test', '0', 'test2', 'key']); expect(types).to.deep.equal([PathHelper.TOKEN_TYPES.RAISE_LEVEL_TOKEN, PathHelper.TOKEN_TYPES.RAISE_LEVEL_TOKEN, PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, PathHelper.TOKEN_TYPES.ARRAY_TOKEN, - PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, PathHelper.TOKEN_TYPES.ARRAY_TOKEN + PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN, PathHelper.TOKEN_TYPES.ARRAY_TOKEN, ]); expect(function() { PathHelper.tokenizePathString('/../test2'); }).to.throw(); - }); }); @@ -237,7 +235,6 @@ describe('PathHelper', function() { }); }); - describe('unquotePathSegment', function() { it('should unquote simple strings', function() { expect(PathHelper.unquotePathSegment('"test"')).to.equal('test'); @@ -373,6 +370,5 @@ describe('PathHelper', function() { expect(res.coverageExtent).to.equal(PathHelper.CoverageExtent.PARTLY_COVERED); expect(res.pathList).to.deep.equal(['a.b.c', 'a.b.d']); }); - }); }); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/schemaValidator.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/schemaValidator.ts index 547499952f50..488272e6ba26 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/schemaValidator.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/schemaValidator.ts @@ -27,17 +27,17 @@ export class SchemaValidator { this.getAllParentsForTemplate(in_templateTypeid, parents, true); return parents[in_baseTypeid] !== undefined; - }; + } hasSchema(typeid: string | number) { return this.schemaMap[typeid] !== undefined; - }; + } register(schema) { this.schemaMap[schema.typeid] = schema; - }; + } - inheritsFromAsync(child, ancestor) { + async inheritsFromAsync(child, ancestor) { return new Promise(function(resolve, reject) { setTimeout(function() { try { @@ -50,7 +50,7 @@ export class SchemaValidator { }); } - hasSchemaAsync = (typeid) => new Promise(function(resolve, reject) { + hasSchemaAsync = async (typeid) => new Promise(function(resolve, reject) { setTimeout(function() { resolve(this.schemaMap[typeid] !== undefined); }, 5); @@ -89,7 +89,7 @@ export class SchemaValidator { this.getAllParentsForTemplate(parents[i], out_parents, undefined); } } - }; + } validate(in_schema, in_previousSchema?, in_async?, in_skipSemver?, in_allowDraft?): any { in_skipSemver = in_skipSemver || false; @@ -115,6 +115,5 @@ export class SchemaValidator { return templateValidator.validate(in_schema, in_previousSchema); } - }; -}; - + } +} diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badBothPropertiesAndTypeid.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badBothPropertiesAndTypeid.ts index 6ebec0d6afe5..7fd2f5d9541c 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badBothPropertiesAndTypeid.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badBothPropertiesAndTypeid.ts @@ -17,10 +17,10 @@ 'id': 'r', 'typeid': 'Float32', 'properties': [ - { 'typeid': 'Int32', 'id': 'ri' } - ] + { 'typeid': 'Int32', 'id': 'ri' }, + ], }], - 'typeid': 'TeamLeoValidation2:ColorID-1.0.0' + 'typeid': 'TeamLeoValidation2:ColorID-1.0.0', }; module.exports = templateSchema; })(); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badInvalidSemverInTypeid.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badInvalidSemverInTypeid.ts index 9e88ad35a696..7a9dc1811234 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badInvalidSemverInTypeid.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badInvalidSemverInTypeid.ts @@ -17,30 +17,30 @@ 'id': 'position', 'properties': [{ 'id': 'x', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'y', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'z', - 'typeid': 'Float32' - } - ] + 'typeid': 'Float32', + }, + ], }, { 'id': 'color', - 'typeid': 'TeamLeoValidation2:ColorID-1.0.0' + 'typeid': 'TeamLeoValidation2:ColorID-1.0.0', }, { 'id': 'normal', 'typeid': 'Float32', 'context': 'array', - 'length': 3 - } + 'length': 3, + }, ], - 'typeid': 'TeamLeoValidation2:PointID-1.0.0.1' + 'typeid': 'TeamLeoValidation2:PointID-1.0.0.1', }; module.exports = templateSchema; })(); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badMissingSemverInTypeid.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badMissingSemverInTypeid.ts index 18a9e2255c6b..4adecaf9adb1 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badMissingSemverInTypeid.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badMissingSemverInTypeid.ts @@ -17,30 +17,30 @@ 'id': 'position', 'properties': [{ 'id': 'x', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'y', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'z', - 'typeid': 'Float32' - } - ] + 'typeid': 'Float32', + }, + ], }, { 'id': 'color', - 'typeid': 'TeamLeoValidation2:ColorID-1.0.0' + 'typeid': 'TeamLeoValidation2:ColorID-1.0.0', }, { 'id': 'normal', 'typeid': 'Float32', 'context': 'array', - 'length': 3 - } + 'length': 3, + }, ], - 'typeid': 'TeamLeoValidation2:PointID' + 'typeid': 'TeamLeoValidation2:PointID', }; module.exports = templateSchema; })(); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badNestedProperties.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badNestedProperties.ts index fe087f7146a0..191b903a1546 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badNestedProperties.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badNestedProperties.ts @@ -15,15 +15,15 @@ var templateSchema = { 'properties': [{ 'id': 'r', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'g', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'b', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'nest', @@ -35,13 +35,13 @@ 'id': 'nestedAgain', 'properties': [ { 'id': 'a', 'typeid': 'Int32' }, - { 'id': 'b', 'typeid': 'Flob' } - ] - } - ] - } + { 'id': 'b', 'typeid': 'Flob' }, + ], + }, + ], + }, ], - 'typeid': 'TeamLeoValidation2:NestedTest-1.0.0' + 'typeid': 'TeamLeoValidation2:NestedTest-1.0.0', }; module.exports = templateSchema; })(); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badPrimitiveTypeid.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badPrimitiveTypeid.ts index 0e36d0e7b6c1..e6140ef739dd 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badPrimitiveTypeid.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badPrimitiveTypeid.ts @@ -15,18 +15,18 @@ var templateSchema = { 'properties': [{ 'id': 'r', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'g', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'b', - 'typeid': 'Flob32' - } + 'typeid': 'Flob32', + }, ], - 'typeid': 'TeamLeoValidation2:ColorID-1.0.0' + 'typeid': 'TeamLeoValidation2:ColorID-1.0.0', }; module.exports = templateSchema; })(); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badVersionedTypeid.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badVersionedTypeid.ts index ddedeb110a56..3d6debac97d1 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badVersionedTypeid.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/badVersionedTypeid.ts @@ -17,31 +17,31 @@ 'id': 'position', 'properties': [{ 'id': 'x', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'y', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'z', - 'typeid': 'Float32' - } - ] + 'typeid': 'Float32', + }, + ], }, { 'id': 'color', - 'typeid': 'TeamLeoValidation2:ColorID-1.0.0' + 'typeid': 'TeamLeoValidation2:ColorID-1.0.0', }, { 'id': 'normal', 'typeid': 'Float32', 'context': 'array', - 'length': 3 - } + 'length': 3, + }, ], '_comment': 'typeid is missing', - 'typeid': 'Int32' + 'typeid': 'Int32', }; module.exports = templateSchema; })(); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodColorPalette.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodColorPalette.ts index 89af88dfa31a..cf97a80802fb 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodColorPalette.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodColorPalette.ts @@ -16,8 +16,8 @@ 'typeid': 'Adsk.Library:Colors.ColorPalette-1.0.0', 'properties': [ { 'id': 'colors', 'typeid': 'Reference', 'context': 'map' }, - { 'id': 'testref', 'typeid': 'Reference', 'context': 'map' } - ] + { 'id': 'testref', 'typeid': 'Reference', 'context': 'map' }, + ], }; module.exports = templateSchema; })(); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodDraftAsVersion.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodDraftAsVersion.ts index d68f569517d8..8514b89fecea 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodDraftAsVersion.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodDraftAsVersion.ts @@ -15,8 +15,8 @@ var templateSchema = { 'typeid': 'autodesk:GoodDraftAsVersion-draft', 'properties': [ - { 'id': 'int', 'typeid': 'Int32' } - ] + { 'id': 'int', 'typeid': 'Int32' }, + ], }; module.exports = templateSchema; })(); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodPointId.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodPointId.ts index c5f646f079bf..33cfbb266573 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodPointId.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodPointId.ts @@ -17,30 +17,30 @@ 'id': 'position', 'properties': [{ 'id': 'x', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'y', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'z', - 'typeid': 'Float32' - } - ] + 'typeid': 'Float32', + }, + ], }, { 'id': 'color', - 'typeid': 'TeamLeoValidation2:ColorID-1.0.0' + 'typeid': 'TeamLeoValidation2:ColorID-1.0.0', }, { 'id': 'normal', 'typeid': 'Float32', 'context': 'array', - 'length': 3 - } + 'length': 3, + }, ], - 'typeid': 'TeamLeoValidation2:PointID-1.0.0' + 'typeid': 'TeamLeoValidation2:PointID-1.0.0', }; module.exports = templateSchema; })(); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodReferenceAndRegular.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodReferenceAndRegular.ts index 9fb22039daa1..bbf7829c2daf 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodReferenceAndRegular.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodReferenceAndRegular.ts @@ -17,8 +17,8 @@ 'properties': [ { 'id': 'colorsRef', 'typeid': 'Reference', 'context': 'map' }, { 'id': 'colors', 'typeid': 'Adsk.Core:Math.Color-1.0.0' }, - { 'id': 'testref', 'typeid': 'Reference', 'context': 'map' } - ] + { 'id': 'testref', 'typeid': 'Reference', 'context': 'map' }, + ], }; module.exports = templateSchema; })(); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodReservedTypes.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodReservedTypes.ts index 91d9bb427957..f978ae82013f 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodReservedTypes.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodReservedTypes.ts @@ -18,13 +18,13 @@ 'inherits': 'NamedProperty', 'properties': [{ 'id': 'exampleProperty1', - 'typeid': 'String' + 'typeid': 'String', }, { 'id': 'exampleProperty2', - 'typeid': 'NodeProperty' - } - ] + 'typeid': 'NodeProperty', + }, + ], }; module.exports = templateSchema; })(); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodUIBorder.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodUIBorder.ts index 33763da98db0..f9c96bd73640 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodUIBorder.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/schemas/goodUIBorder.ts @@ -20,8 +20,8 @@ 'properties': [ { 'id': 'solid', 'value': 200, 'annotation': { 'description': 'solid line' } }, { 'id': 'dashed', 'value': 100, 'annotation': { 'description': 'dashed line' } }, - { 'id': 'dotted', 'value': 300, 'annotation': { 'description': 'dotted line' } } - ] + { 'id': 'dotted', 'value': 300, 'annotation': { 'description': 'dotted line' } }, + ], }, { 'id': 'style', @@ -29,12 +29,12 @@ 'id': 'thickness', 'typeid': 'Uint32', 'annotation': { - 'description': 'border thickness in Pixels' + 'description': 'border thickness in Pixels', }, - 'unit': 'Adsk.Core:Units.Imaging-1.0.0' - }] - } - ] + 'unit': 'Adsk.Core:Units.Imaging-1.0.0', + }], + }, + ], }; module.exports = templateSchema; })(); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/validator/templateValidator.spec.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/validator/templateValidator.spec.ts index 650f55a8bdb6..7dd792588e53 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/validator/templateValidator.spec.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/validator/templateValidator.spec.ts @@ -26,7 +26,7 @@ import { TemplateValidator } from "../../templateValidator"; expect(error.message).to.have.string(asyncErrorMessage); }); } else { - return new Promise(resolve => { + return new Promise((resolve) => { resolve(schemaValidator.validate(template, templatePrevious, async, skipSemver)); }); } @@ -238,7 +238,7 @@ import { TemplateValidator } from "../../templateValidator"; it("fail: changed 'inherits'", function() { let templatePrevious = JSON.parse(JSON.stringify( - require('../schemas/goodReservedTypes') + require('../schemas/goodReservedTypes'), )); let template = JSON.parse(JSON.stringify(templatePrevious)); template.inherits = 'Reference'; @@ -395,7 +395,7 @@ import { TemplateValidator } from "../../templateValidator"; it("warn: changed 'inherits'", function() { let templatePrevious = JSON.parse(JSON.stringify( - require('../schemas/goodReservedTypes') + require('../schemas/goodReservedTypes'), )); let template = JSON.parse(JSON.stringify(templatePrevious)); template.typeid = 'TeamLeoValidation2:Example-' + semver.inc('1.0.0', 'patch'); @@ -541,7 +541,7 @@ import { TemplateValidator } from "../../templateValidator"; it("warn: changed 'inherits'", function() { let templatePrevious = JSON.parse(JSON.stringify( - require('../schemas/goodReservedTypes') + require('../schemas/goodReservedTypes'), )); let template = JSON.parse(JSON.stringify(templatePrevious)); template.typeid = 'TeamLeoValidation2:Example-' + semver.inc('1.0.0', 'minor'); @@ -685,7 +685,7 @@ import { TemplateValidator } from "../../templateValidator"; it("pass: changed 'inherits'", function() { let templatePrevious = JSON.parse(JSON.stringify( - require('../schemas/goodReservedTypes') + require('../schemas/goodReservedTypes'), )); let template = JSON.parse(JSON.stringify(templatePrevious)); template.typeid = 'TeamLeoValidation2:Example-' + semver.inc('1.0.0', 'major'); @@ -774,7 +774,7 @@ import { TemplateValidator } from "../../templateValidator"; let copies = [ JSON.parse(JSON.stringify(templatePrevious)), - JSON.parse(JSON.stringify(template)) + JSON.parse(JSON.stringify(template)), ]; let expectations = function(result) { @@ -831,7 +831,7 @@ import { TemplateValidator } from "../../templateValidator"; it('should pass a schema with an empty array of properties', function() { let EmptyPropertySchema = { typeid: 'Test:EmptyPropertySchema-1.0.0', - properties: [] + properties: [], }; let expectations = function(result) { @@ -861,10 +861,10 @@ import { TemplateValidator } from "../../templateValidator"; it('fail: deep equal with out of order multiple inheritance', function() { let template = JSON.parse('{"typeid":"autodesk.core:translation.controller-1.0.0",' + - '"inherits":["NamedProperty","NodeProperty"]}' + '"inherits":["NamedProperty","NodeProperty"]}', ); let templatePrevious = JSON.parse('{"typeid":"autodesk.core:translation.controller-1.0.0",' + - '"inherits":["NodeProperty","NamedProperty"]}' + '"inherits":["NodeProperty","NamedProperty"]}', ); let expectations = function(result) { @@ -882,10 +882,10 @@ import { TemplateValidator } from "../../templateValidator"; describe('pass: deep equal between no properties and an empty properties array', () => { let templateArray = { typeid: 'SimpleTest:Shape-1.0.0', - properties: [] + properties: [], }; let templateAbstract = { - typeid: 'SimpleTest:Shape-1.0.0' + typeid: 'SimpleTest:Shape-1.0.0', }; it('source is abstract and target is an empty properties array', function() { @@ -920,7 +920,7 @@ import { TemplateValidator } from "../../templateValidator"; new TemplateValidator({ skipSemver: true, inheritsFrom: schemaValidator.inheritsFrom as any, - hasSchema: schemaValidator.hasSchema as any + hasSchema: schemaValidator.hasSchema as any, }); }); @@ -937,7 +937,7 @@ import { TemplateValidator } from "../../templateValidator"; it('should pass a valid template', function() { let ConstantValid = { typeid: 'ConstantTest:ConstantValid-1.0.0', - constants: [{ id: 'valid', typeid: 'String', value: 'value' }] + constants: [{ id: 'valid', typeid: 'String', value: 'value' }], }; let expectations = function(result) { @@ -951,7 +951,7 @@ import { TemplateValidator } from "../../templateValidator"; it('should fail if constants array has no elements', function() { let ConstantEmptyArray = { typeid: 'ConstantTest:ConstantEmptyArray-1.0.0', - constants: [] + constants: [], }; return validate(expectationsGenerator('/constants should NOT have fewer than 1 items'), @@ -961,7 +961,7 @@ import { TemplateValidator } from "../../templateValidator"; it('should fail if constant does not have an id', function() { let ConstantNoId = { typeid: 'ConstantTest:ConstantNoId-1.0.0', - constants: [{ typeid: 'String', value: 'value' }] + constants: [{ typeid: 'String', value: 'value' }], }; return validate(expectationsGenerator('/constants/0 should have required property \'id\''), @@ -971,19 +971,19 @@ import { TemplateValidator } from "../../templateValidator"; it('should fail if constant does not have a typeid', function() { let ConstantNoTypeid = { typeid: 'ConstantTest:ConstantNoTypeid-1.0.0', - constants: [{ id: 'id', value: 'value' }] + constants: [{ id: 'id', value: 'value' }], }; return validate( function(result) { expect(result.isValid).to.equal(false); - //console.log(result.errors); + // console.log(result.errors); expect(result.errors.length).to.equal(5); expect(result.errors[3].message).to.include("should have required property 'inherits'"); expect(result.errors[4].message).to.include("/constants/0 should have required property 'typeid'"); return result; }, - ConstantNoTypeid, null, true + ConstantNoTypeid, null, true, ); }); @@ -991,7 +991,7 @@ import { TemplateValidator } from "../../templateValidator"; let ConstantNoTypeid = { typeid: 'ConstantTest:ConstantNoTypeid-1.0.0', inherits: 'ConstantTest:ConstantParentWithTypeid-1.0.0', - constants: [{ id: 'id', value: 'value' }] + constants: [{ id: 'id', value: 'value' }], }; let expectations = function(result) { @@ -1005,7 +1005,7 @@ import { TemplateValidator } from "../../templateValidator"; it('should not fail if constant does not have a value or typedValue', function() { let ConstantNoValue = { typeid: 'ConstantTest:ConstantNoValue-1.0.0', - constants: [{ id: 'id', typeid: 'String' }] + constants: [{ id: 'id', typeid: 'String' }], }; let expectations = function(result) { @@ -1024,8 +1024,8 @@ import { TemplateValidator } from "../../templateValidator"; typeid: 'Int32', context: 'map', contextKeyType: 'typeid', - value: { 'SimpleTest:ConstantTemplate1-1.0.0': 1, 'SimpleTest:ConstantTemplate2-1.0.0': -1 } - }] + value: { 'SimpleTest:ConstantTemplate1-1.0.0': 1, 'SimpleTest:ConstantTemplate2-1.0.0': -1 }, + }], }; let expectations = function(result) { @@ -1044,8 +1044,8 @@ import { TemplateValidator } from "../../templateValidator"; typeid: 'Int32', context: 'map', contextKeyType: 'badvalue', - value: { 'SimpleTest:ConstantTemplate1-1.0.0': 1, 'SimpleTest:ConstantTemplate2-1.0.0': -1 } - }] + value: { 'SimpleTest:ConstantTemplate1-1.0.0': 1, 'SimpleTest:ConstantTemplate2-1.0.0': -1 }, + }], }; return validate( @@ -1057,7 +1057,7 @@ import { TemplateValidator } from "../../templateValidator"; }, ConstantNoValue, null, - true + true, ); }); @@ -1069,8 +1069,8 @@ import { TemplateValidator } from "../../templateValidator"; typeid: 'Int32', context: 'map', contextKeyType: 'typeid', - value: { 'NotATypeId': 1, 'AlsoNotATypeId': -1 } - }] + value: { 'NotATypeId': 1, 'AlsoNotATypeId': -1 }, + }], }; let expectations = function(result) { @@ -1095,8 +1095,8 @@ import { TemplateValidator } from "../../templateValidator"; typeid: 'Int32', context: 'map', contextKeyType: 'typeid', - value: { 'SimpleTest:ConstantTemplate1-1.0.0': 1, 'SimpleTest:ConstantTemplate2-1.0.0': -1 } - }] + value: { 'SimpleTest:ConstantTemplate1-1.0.0': 1, 'SimpleTest:ConstantTemplate2-1.0.0': -1 }, + }], }; let expectations = function(result) { @@ -1117,17 +1117,17 @@ import { TemplateValidator } from "../../templateValidator"; let templateValidator = new TemplateValidator({ inheritsFromAsync: schemaValidator.inheritsFromAsync as any, - hasSchemaAsync: schemaValidator.hasSchemaAsync as any + hasSchemaAsync: schemaValidator.hasSchemaAsync as any, }); // Doesn't inherit from 'NamedProperty'. Will cause an error let grandParentSchema = { - 'typeid': 'test:grandparentschema-1.0.0' + 'typeid': 'test:grandparentschema-1.0.0', }; let parentSchema = { 'typeid': 'test:parentschema-1.0.0', - 'inherits': ['test:grandparentschema-1.0.0'] + 'inherits': ['test:grandparentschema-1.0.0'], }; let childSchema = { @@ -1135,8 +1135,8 @@ import { TemplateValidator } from "../../templateValidator"; properties: [{ id: 'set', typeid: 'test:parentschema-1.0.0', - context: 'set' - }] + context: 'set', + }], }; schemaValidator.register(grandParentSchema); @@ -1146,10 +1146,10 @@ import { TemplateValidator } from "../../templateValidator"; () => { done(new Error('Should not be valid!')); }, - error => { + (error) => { expect(error).to.exist; done(); - } + }, ); }); }); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/test/validator/typeidHelper.spec.ts b/experimental/PropertyDDS/packages/property-changeset/src/test/validator/typeidHelper.spec.ts index d2088b6976eb..1391e2b4dfe2 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/test/validator/typeidHelper.spec.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/test/validator/typeidHelper.spec.ts @@ -20,7 +20,7 @@ import { TypeIdHelper } from '../../helpers/typeidHelper'; it('getPrimitiveTypeId() should return all primitive typeids', () => { const result = TypeIdHelper.getPrimitiveTypeIds(); expect(result).to.have.members(['Float32', 'Float64', 'Int8', 'Uint8', 'Int16', 'Uint16', 'Int32', - 'Uint32', 'Bool', 'String', 'Reference', 'Enum', 'Int64', 'Uint64' + 'Uint32', 'Bool', 'String', 'Reference', 'Enum', 'Int64', 'Uint64', ]); }); @@ -28,7 +28,7 @@ import { TypeIdHelper } from '../../helpers/typeidHelper'; const result = TypeIdHelper.getReservedTypeIds(); expect(result).to.have.members(['BaseProperty', 'ContainerProperty', 'NamedProperty', 'NodeProperty', - 'NamedNodeProperty', 'RelationshipProperty' + 'NamedNodeProperty', 'RelationshipProperty', ]); }); diff --git a/experimental/PropertyDDS/packages/property-changeset/src/utils.ts b/experimental/PropertyDDS/packages/property-changeset/src/utils.ts index ade21388ff4e..04476da02d72 100644 --- a/experimental/PropertyDDS/packages/property-changeset/src/utils.ts +++ b/experimental/PropertyDDS/packages/property-changeset/src/utils.ts @@ -2,7 +2,7 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -//@ts-ignore +// @ts-ignore import { ConsoleUtils, constants } from "@fluid-experimental/property-common"; import { eachOfSeries, eachSeries, ErrorCallback, series, timesSeries, whilst } from "async"; @@ -20,11 +20,10 @@ import { ArrayChangeSetIterator } from "./changeset_operations/arrayChangesetIte import { ExtractedContext, TypeIdHelper } from "./helpers/typeidHelper"; import { isReservedKeyword } from "./isReservedKeyword"; import { PathHelper, PathTree } from "./pathHelper"; -import { ArrayIteratorOperationTypes } from "./changeset_operations/operationTypes" +import { ArrayIteratorOperationTypes } from "./changeset_operations/operationTypes"; const { PROPERTY_PATH_DELIMITER, MSG } = constants; - type NextFn = (err?: Error | null | undefined | string, result?: unknown) => void; /** @@ -84,7 +83,7 @@ export namespace Utils { // Call the callback function for this ChangeSet in_context._traversalStopped = false; - const typeid = in_context.getTypeid() + const typeid = in_context.getTypeid(); let splitTypeId = typeid !== undefined ? TypeIdHelper.extractContext(typeid) : undefined; @@ -505,7 +504,7 @@ export namespace Utils { in_levelCallback(err); } }); - }; + } /** * Copies a change set into an object that is meant to be a placeholder for the next @@ -573,7 +572,6 @@ export namespace Utils { return nestedChangeSet; }; - /** * Traverses a ChangeSet recursively and invokes the callback for each visited property. * @@ -1023,7 +1021,7 @@ export namespace Utils { } } - /**- + /** * Get the ChangeSet of the parent that contains the currently visited node. * * @returns The parent ChangeSet @@ -1047,7 +1045,6 @@ export namespace Utils { this._splitTypeId = splitTypeid; } - /** * Sets user data, which will be passed to the recursive calls within this scope * @@ -2111,4 +2108,4 @@ export namespace Utils { return paths; } -}; +} diff --git a/experimental/PropertyDDS/packages/property-common/package.json b/experimental/PropertyDDS/packages/property-common/package.json index 6808511d19b9..f5b99bd6e0eb 100644 --- a/experimental/PropertyDDS/packages/property-common/package.json +++ b/experimental/PropertyDDS/packages/property-common/package.json @@ -65,7 +65,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/experimental/PropertyDDS/packages/property-dds/package.json b/experimental/PropertyDDS/packages/property-dds/package.json index 49c94aa505be..e01d9572b15e 100644 --- a/experimental/PropertyDDS/packages/property-dds/package.json +++ b/experimental/PropertyDDS/packages/property-dds/package.json @@ -51,7 +51,7 @@ "@fluid-experimental/property-common": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", "@fluidframework/driver-definitions": "^0.45.0-0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/local-driver": "^0.58.1000", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/sequence": "^0.58.1000", diff --git a/experimental/PropertyDDS/packages/property-dds/src/test/rebasing.spec.ts b/experimental/PropertyDDS/packages/property-dds/src/test/rebasing.spec.ts index 515de259963f..3af413657852 100644 --- a/experimental/PropertyDDS/packages/property-dds/src/test/rebasing.spec.ts +++ b/experimental/PropertyDDS/packages/property-dds/src/test/rebasing.spec.ts @@ -960,9 +960,9 @@ describe("PropertyDDS", () => { // Make local changes for both collaborators prop.setValue(val1); - sharedPropertyTree2.root.get('int32Prop')?.setValue(val2); + sharedPropertyTree2.root.get("int32Prop")?.setValue(val2); - sharedPropertyTree1.commit() + sharedPropertyTree1.commit(); await opProcessingController.ensureSynchronized(); await opProcessingController.pauseProcessing(); @@ -976,11 +976,8 @@ describe("PropertyDDS", () => { // The pending change val2 should be now the new value cross collaborators expect(prop.getValue()).to.equal(val2); - }); - }); - } describe("Rebasing", () => { diff --git a/experimental/PropertyDDS/packages/property-properties/.eslintrc.js b/experimental/PropertyDDS/packages/property-properties/.eslintrc.js index 3d7cd30afa73..7e0f46c61204 100644 --- a/experimental/PropertyDDS/packages/property-properties/.eslintrc.js +++ b/experimental/PropertyDDS/packages/property-properties/.eslintrc.js @@ -13,12 +13,44 @@ module.exports = { "rules": { "@typescript-eslint/ban-types": "off", "@typescript-eslint/dot-notation": "off", + "@typescript-eslint/no-dynamic-delete": "off", + "@typescript-eslint/no-extraneous-class": "off", + "@typescript-eslint/no-extraneous-dependencies": "off", + "@typescript-eslint/no-implied-eval": "off", + "@typescript-eslint/no-require-imports": "off", + "@typescript-eslint/no-shadow": "off", + "@typescript-eslint/no-this-alias": "off", "@typescript-eslint/no-unnecessary-type-assertion": "off", + "@typescript-eslint/no-unsafe-argument": "off", + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-return": "off", + "@typescript-eslint/no-unused-expressions": "off", + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/prefer-for-of": "off", + "@typescript-eslint/quotes": "off", + "@typescript-eslint/restrict-plus-operands": "off", + "@typescript-eslint/strict-boolean-expressions": "off", + "guard-for-in": "off", "import/no-duplicates": "off", + "import/no-internal-modules": "off", "max-len": "off", "no-bitwise": "off", + "no-new-func": "off", + "no-param-reassign": "off", + "no-prototype-builtins": "off", + "no-restricted-syntax": "off", + "no-undef": "off", + "no-undef-init": "off", "no-var": "off", + "object-shorthand": "off", + "one-var": "off", + "prefer-arrow-callback": "off", "prefer-const": "off", + "prefer-object-spread": "off", + "prefer-template": "off", + "quote-props": "off", "unicorn/better-regex": "off", "unicorn/no-unsafe-regex": "off" } diff --git a/experimental/PropertyDDS/packages/property-properties/package.json b/experimental/PropertyDDS/packages/property-properties/package.json index bada5ef96dc2..4c0e4d5ee974 100644 --- a/experimental/PropertyDDS/packages/property-properties/package.json +++ b/experimental/PropertyDDS/packages/property-properties/package.json @@ -61,13 +61,16 @@ "@fluid-experimental/property-common": "^0.58.1000", "ajv": "7.1.1", "async": "^3.2.0", + "fastest-json-copy": "^1.0.1", "lodash": "^4.17.21", "semver": "^7.3.4", - "traverse": "0.6.6" + "traverse": "0.6.6", + "underscore": "^1.12.1" }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", "@fluidframework/mocha-test-setup": "^0.58.1000", + "@types/mocha": "^8.2.2", "chai": "^4.2.0", "concurrently": "^6.2.0", "cross-env": "^7.0.2", diff --git a/experimental/PropertyDDS/packages/property-properties/src/containerSerializer.js b/experimental/PropertyDDS/packages/property-properties/src/containerSerializer.js index ffcde2eb3858..5f74d3976d2d 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/containerSerializer.js +++ b/experimental/PropertyDDS/packages/property-properties/src/containerSerializer.js @@ -5,13 +5,12 @@ /** * @namespace property-properties */ -const { LazyLoadedProperties: Property } = require('./properties/lazyLoadedProperties'); -const { AbstractStaticCollectionProperty } = require('./properties/abstractStaticCollectionProperty') const { PathHelper } = require('@fluid-experimental/property-changeset'); - +const { LazyLoadedProperties: Property } = require('./properties/lazyLoadedProperties'); +const { AbstractStaticCollectionProperty } = require('./properties/abstractStaticCollectionProperty'); var MSG = { - NOTHING_TO_DESERIALIZE: 'Repository deserialize(), no input given' + NOTHING_TO_DESERIALIZE: 'Repository deserialize(), no input given', }; /** @@ -28,15 +27,14 @@ class ScopeProperty extends AbstractStaticCollectionProperty { // at this point. There may be a bug with MR. super(in_params); this._scope = in_params.scope; - }; - + } /** * @override */ _getScope() { return this._scope; - }; + } /** * Remove a child property @@ -53,7 +51,7 @@ class ScopeProperty extends AbstractStaticCollectionProperty { } else { throw new Error(MSG.REMOVING_NON_EXISTING_ID + in_id); } - }; + } } /** @@ -64,7 +62,6 @@ class ScopeProperty extends AbstractStaticCollectionProperty { * @alias property-properties.serialize */ export function serialize(in_psets, in_dirtyOnly) { - in_dirtyOnly = in_dirtyOnly || false; var documentData = {}; @@ -79,9 +76,8 @@ export function serialize(in_psets, in_dirtyOnly) { documentData[rootTypeid][keys[i]] = in_psets[keys[i]].serialize(in_dirtyOnly); } - return documentData; -}; +} /** * Deserialize the input document @@ -93,7 +89,6 @@ export function serialize(in_psets, in_dirtyOnly) { * @alias property-properties.deserialize */ export function deserialize(in_data, in_scope, in_filteringOptions) { - if (!in_data) { console.warn(MSG.NOTHING_TO_DESERIALIZE); return {}; @@ -110,7 +105,7 @@ export function deserialize(in_data, in_scope, in_filteringOptions) { case PathHelper.CoverageExtent.PARTLY_COVERED: baseFilteringOptions = { basePath: in_filteringOptions.basePath, - paths: pathCoverage.pathList + paths: pathCoverage.pathList, }; break; case PathHelper.CoverageExtent.UNCOVERED: @@ -133,7 +128,7 @@ export function deserialize(in_data, in_scope, in_filteringOptions) { // reconstruct entity let filteringOptions = baseFilteringOptions && { basePath: PathHelper.getChildAbsolutePathCanonical(baseFilteringOptions.basePath, classKeys[iClass]), - paths: baseFilteringOptions.paths + paths: baseFilteringOptions.paths, }; // TODO: In theory this could throw when the entity can not be created because it is not included // in the paths. Make sure to handle this case when we'll add that validation. @@ -160,7 +155,7 @@ export function deserialize(in_data, in_scope, in_filteringOptions) { } return deserializedProperties; -}; +} /** * Deserialize the input document assuming it contains elements of a non-primitive array. * @param {array} in_data the input JSON document data @@ -169,7 +164,6 @@ export function deserialize(in_data, in_scope, in_filteringOptions) { * @alias property-properties.deserializeNonPrimitiveArrayElements */ export function deserializeNonPrimitiveArrayElements(in_data, in_scope) { - if (!in_data) { console.warn(MSG.NOTHING_TO_DESERIALIZE); return []; @@ -198,5 +192,4 @@ export function deserializeNonPrimitiveArrayElements(in_data, in_scope) { } return insertedPropertyInstances; -}; - +} diff --git a/experimental/PropertyDDS/packages/property-properties/src/enableValidations.ts b/experimental/PropertyDDS/packages/property-properties/src/enableValidations.ts index fc171b489ca6..e1916efa28dd 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/enableValidations.ts +++ b/experimental/PropertyDDS/packages/property-properties/src/enableValidations.ts @@ -4,8 +4,8 @@ */ export let validationsEnabled = { - enabled: true -} + enabled: true, +}; /** * Switch off validation to increase performance (but you risk modifying read only properties, creating cycles in @@ -13,6 +13,6 @@ export let validationsEnabled = { * * @param enabled - Are the validations enabled? */ -export function enableValidations(enabled : boolean) { +export function enableValidations(enabled: boolean) { validationsEnabled.enabled = enabled; } diff --git a/experimental/PropertyDDS/packages/property-properties/src/index.ts b/experimental/PropertyDDS/packages/property-properties/src/index.ts index 406cef5e25ae..f086db1abc55 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/index.ts +++ b/experimental/PropertyDDS/packages/property-properties/src/index.ts @@ -23,7 +23,6 @@ import { ValueMapProperty } from './properties/valueMapProperty'; import { ValueProperty } from './properties/valueProperty'; import { enableValidations } from './enableValidations'; - export { PropertyFactory, PropertyUtils, @@ -44,5 +43,5 @@ export { ValueArrayProperty, ValueMapProperty, ValueProperty, - enableValidations -} + enableValidations, +}; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/abstractStaticCollectionProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/abstractStaticCollectionProperty.js index f6b252ba45b7..d36dad69fc05 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/abstractStaticCollectionProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/abstractStaticCollectionProperty.js @@ -3,9 +3,9 @@ * Licensed under the MIT License. */ const _ = require('lodash'); -const { BaseProperty } = require('./baseProperty'); const { ConsoleUtils, constants } = require('@fluid-experimental/property-common'); const { PathHelper, ChangeSet } = require('@fluid-experimental/property-changeset'); +const { BaseProperty } = require('./baseProperty'); const { LazyLoadedProperties: Property } = require('./lazyLoadedProperties'); const { MSG, PROPERTY_PATH_DELIMITER } = constants; @@ -30,7 +30,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { this._staticChildren = {}; } this._constantChildren = {}; - }; + } /** * Returns the sub-property having the given name, or following the given paths, in this property. @@ -93,7 +93,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { } return prop; - }; + } /** * Returns the sub-property having the given name in this property. @@ -104,7 +104,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { */ _get(in_id) { return this._staticChildren[in_id] || this._constantChildren[in_id]; - }; + } /** * Returns a string identifying the property @@ -119,7 +119,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { } else { return this.getGuid(); } - }; + } /** * Returns the GUID of this named property @@ -131,7 +131,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { getGuid() { var guid = this.get('guid', { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER }); return guid ? guid.value : undefined; - }; + } /** * returns the value of a sub-property @@ -153,8 +153,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { ConsoleUtils.assert((property instanceof Property.ValueProperty || property instanceof Property.StringProperty), MSG.GET_VALUE_NOT_A_VALUE + in_ids); return property.getValue(); - }; - + } /** * Get all sub-properties of the current property. @@ -171,8 +170,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { res[ids[i]] = this.get(ids[i], { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER }); } return res; - }; - + } /** * Returns the name of all the sub-properties of this property. @@ -181,7 +179,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { */ getIds() { return this._getIds(); - }; + } /** * Returns the name of all the sub-properties of this property. @@ -190,9 +188,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { */ _getIds() { return Object.keys(this._staticChildren).concat(Object.keys(this._constantChildren)); - }; - - + } /** * Returns an object with all the nested values contained in this property @@ -218,7 +214,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { } } return result; - }; + } /** * Checks whether a property with the given name exists @@ -228,7 +224,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { */ has(in_id) { return this._get(in_id) !== undefined; - }; + } /** * Expand a path returning the property or value at the end. @@ -269,7 +265,6 @@ export class AbstractStaticCollectionProperty extends BaseProperty { } iterationStart++; } - } } } @@ -290,8 +285,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { } } return node; - - }; + } /** * Returns the path segment for a child @@ -303,7 +297,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { */ _getPathSegmentForChildNode(in_childNode) { return PROPERTY_PATH_DELIMITER + PathHelper.quotePathSegmentIfNeeded(in_childNode.getId()); - }; + } /** * Resolves a direct child node based on the given path segment @@ -325,7 +319,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { } else { return undefined; } - }; + } /** * Given an object that mirrors a PSet Template, assigns the properties to the values @@ -358,7 +352,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { throw new Error(MSG.SET_VALUES_PATH_INVALID + propertyKey); } } - }; + } /** * Given an object that mirrors a PSet Template, assigns the properties to the values @@ -387,7 +381,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { } else { AbstractStaticCollectionProperty.prototype._setValues.call(this, in_values, false, false); } - }; + } /** * Append a child property @@ -425,7 +419,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { throw new Error(MSG.OVERRIDDING_INHERITED_TYPES + id); } } - }; + } /** * Merge child properties @@ -442,7 +436,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { for (var i = 0; i < keys.length; i++) { this._append(in_property._staticChildren[keys[i]], true); } - }; + } /** * @inheritdoc @@ -458,7 +452,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { } return rtn; - }; + } /** * Traverses the property hierarchy downwards until all child properties are reached @@ -472,7 +466,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { traverseDown(in_callback) { ConsoleUtils.assert(_.isFunction(in_callback), MSG.CALLBACK_NOT_FCT); return this._traverse(in_callback, ''); - }; + } /** * Traverses all children in the child hierarchy @@ -507,7 +501,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { } return undefined; - }; + } /** * Traverses all static properties (properties declared in the template and not added dynamically) in the @@ -536,7 +530,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { } in_callback(property, childPath); } - }; + } /** * Serialize the property into a changeSet @@ -559,7 +553,6 @@ export class AbstractStaticCollectionProperty extends BaseProperty { in_includeRootTypeid, in_dirtinessType, in_includeReferencedRepositories) { - var serializedChildren = {}; var childrenType; @@ -567,8 +560,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { in_dirtinessType = in_dirtinessType === undefined ? BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE : in_dirtinessType; - this._traverseStaticProperties(function (in_node, in_pathFromTraversalStart) { - + this._traverseStaticProperties(function(in_node, in_pathFromTraversalStart) { if (in_dirtyOnly && !in_node._isDirty(in_dirtinessType)) { return; } @@ -599,7 +591,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { } return serializedChildren; - }; + } /** * Sets the property to the state in the given normalized changeset @@ -614,11 +606,10 @@ export class AbstractStaticCollectionProperty extends BaseProperty { * deserialization */ _deserialize(in_serializedObj, in_reportToView) { - var changeSet = {}; // Traverse all properties of this template - this._traverseStaticProperties(function (in_node, in_pathFromTraversalStart) { + this._traverseStaticProperties(function(in_node, in_pathFromTraversalStart) { // We do not deserialize base properties, since the traverseStatic function // already traverses recursively if (in_node.getTypeid() === 'ContainerProperty' && in_node.getContext() === 'single') { @@ -653,7 +644,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { this._reportDirtinessToView(); } return changeSet; - }; + } /** * Get a flattened, tree like representation of this object and all of it's @@ -683,7 +674,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { flattenedRepresentation.propertyNode = this; return flattenedRepresentation; - }; + } /** * Returns the number of children this node has @@ -692,7 +683,7 @@ export class AbstractStaticCollectionProperty extends BaseProperty { */ _getChildrenCount() { return this._getIds().length; - }; + } /** * Sets constants @@ -702,6 +693,5 @@ export class AbstractStaticCollectionProperty extends BaseProperty { ConsoleUtils.assert(_.isObject(in_constants), MSG.ASSERTION_FAILED + ' setConstants parameter: in_constants must be an object.'); this._constantChildren = in_constants; - }; - + } } diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/arrayProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/arrayProperty.js index 3ef0cd379311..b8616980fc5f 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/arrayProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/arrayProperty.js @@ -5,23 +5,23 @@ /** * @fileoverview Definition of the array property class */ -const _ = require('lodash'); -const { BaseProperty } = require('./baseProperty'); -const { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty'); -const { deserializeNonPrimitiveArrayElements } = require('../containerSerializer'); const { ArrayChangeSetIterator, ChangeSet, PathHelper, - TypeIdHelper + TypeIdHelper, } = require('@fluid-experimental/property-changeset'); const { MSG } = require('@fluid-experimental/property-common').constants; -const { LazyLoadedProperties: Property } = require('./lazyLoadedProperties'); const { UniversalDataArray, ConsoleUtils } = require('@fluid-experimental/property-common'); const fastestJSONCopy = require('fastest-json-copy'); -const deepCopy = fastestJSONCopy.copy; +const _ = require('lodash'); +const { deserializeNonPrimitiveArrayElements } = require('../containerSerializer'); const { validationsEnabled } = require('../enableValidations'); +const { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty'); +const { BaseProperty } = require('./baseProperty'); +const { LazyLoadedProperties: Property } = require('./lazyLoadedProperties'); +const deepCopy = fastestJSONCopy.copy; var MODIFIED_STATE_FLAGS = BaseProperty.MODIFIED_STATE_FLAGS; @@ -35,26 +35,25 @@ var MODIFIED_STATE_FLAGS = BaseProperty.MODIFIED_STATE_FLAGS; var DIRTY_AND_PENDING_CHILD_CHANGES = { pending: undefined, dirty: undefined, - flags: MODIFIED_STATE_FLAGS.PENDING_CHANGE | MODIFIED_STATE_FLAGS.DIRTY + flags: MODIFIED_STATE_FLAGS.PENDING_CHANGE | MODIFIED_STATE_FLAGS.DIRTY, }; var PENDING_CHILD_CHANGES = { pending: undefined, dirty: undefined, - flags: MODIFIED_STATE_FLAGS.PENDING_CHANGE + flags: MODIFIED_STATE_FLAGS.PENDING_CHANGE, }; var DIRTY_CHILD_CHANGES = { pending: undefined, dirty: undefined, - flags: MODIFIED_STATE_FLAGS.DIRTY + flags: MODIFIED_STATE_FLAGS.DIRTY, }; var DIRTY_STATE_FLAGS_ARRAY = [ undefined, PENDING_CHILD_CHANGES, DIRTY_CHILD_CHANGES, - DIRTY_AND_PENDING_CHILD_CHANGES + DIRTY_AND_PENDING_CHILD_CHANGES, ]; - var PATH_TOKENS = BaseProperty.PATH_TOKENS; /** @@ -71,7 +70,7 @@ var PATH_TOKENS = BaseProperty.PATH_TOKENS; * @return {Array.} List of the selected segments, given as indices of the segments * @private */ -var _getLongestIncreasingSubsequenceSegments = function (in_segmentStarts, in_segmentLengths) { +var _getLongestIncreasingSubsequenceSegments = function(in_segmentStarts, in_segmentLengths) { if (in_segmentStarts.length === 0) { return []; } @@ -97,7 +96,7 @@ var _getLongestIncreasingSubsequenceSegments = function (in_segmentStarts, in_se sequenceLength: in_segmentLengths[i] + (lastEntry ? lastEntry.sequenceLength : 0), segmentIndex: i, sequenceLastEntry: currentSegmentStart + in_segmentLengths[i] - 1, - previousEntry: lastEntry + previousEntry: lastEntry, }; // Search for the insertion position for this entry @@ -141,7 +140,6 @@ var _getLongestIncreasingSubsequenceSegments = function (in_segmentStarts, in_se }; export class ArrayProperty extends AbstractStaticCollectionProperty { - /** * Default constructor for ArrayProperty * @param {Object} [in_params] - the parameters @@ -162,7 +160,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } this._dataArrayCreate(length); - }; + } /** * Returns the path segment for a child @@ -173,14 +171,13 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { * @protected */ _getPathSegmentForChildNode(in_childNode) { - var index = this._dataArrayGetBuffer().indexOf(in_childNode); if (index === -1) { throw new Error(MSG.GET_PATH_SEGMENT_CALLED_FOR_NON_ENTRY); } return '[' + index + ']'; - }; + } /** * Resolves a direct child node based on the given path segment @@ -210,7 +207,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } else { return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType); } - }; + } /** * Insert into the array at a given position. @@ -224,7 +221,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ insert(in_position, in_value) { this.insertRange(in_position, [in_value]); - }; + } /** * Is this property a leaf node with regard to flattening? @@ -235,7 +232,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ _isFlattenLeaf() { return true; - }; + } /** * Add one or more values at the end of the array @@ -252,7 +249,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { this.insertRange(this._dataArrayGetLength(), [in_values]); } return this._dataArrayGetLength(); - }; + } /** * Add elements to the end of the queue (array) @@ -278,7 +275,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { this.insertRange(0, [in_values]); } return this._dataArrayGetLength(); - }; + } /** * Removes an element of the array (or a letter in a StringProperty) and shifts remaining elements to the left @@ -294,7 +291,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { var value = this.get(in_position); this.removeRange(in_position, 1); return value; - }; + } /** * Removes the last element of the array or the last letter of a string (for StringProperty) @@ -310,7 +307,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } else { return undefined; } - }; + } /** * Removes an element from the front of the array or a letter from the beginning of a string (for StringProperty) @@ -324,7 +321,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } else { return undefined; } - }; + } /** * Removes elements from the front of the queue (array) @@ -346,7 +343,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { throw new Error(MSG.ARRAY_SET_ONE_ELEMENT + in_value); } this.setRange(in_position, [in_value]); - }; + } /** * Sets the values of items in the array. @@ -384,7 +381,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } else { this._setValuesInternal(in_values); } - }; + } /** * @param {Array<*>|Object} in_values an array or object containing the values to be set. @@ -397,7 +394,9 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { if (_.isArray(in_values)) { this.clear(); this.insertRange(0, in_values); - } else AbstractStaticCollectionProperty.prototype.setValues.call(this, in_values); + } else { + AbstractStaticCollectionProperty.prototype.setValues.call(this, in_values); + } } else { if (_.isArray(in_values) && in_values.length < this._dataArrayGetLength()) { this.removeRange(in_values.length, this._dataArrayGetLength() - in_values.length); @@ -405,7 +404,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { var that = this; var maxIndex = this._dataArrayGetLength() - 1; - _.each(in_values, function (value, index) { + _.each(in_values, function(value, index) { if (index > maxIndex) { that.insert(index, value); } else { @@ -415,7 +414,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } }); } - }; + } /** * Sets the values of items in the array. @@ -436,7 +435,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } else { ArrayProperty.prototype._setValues.call(this, in_values, false, false); } - }; + } /** * Deletes all values from an array @@ -445,7 +444,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { if (this.getLength()) { this.removeRange(0, this.getLength()); } - }; + } /** * @return {Array<*> | String} all values in the ArrayProperty @@ -455,7 +454,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ getEntriesReadOnly() { return this._dataArrayGetBuffer(); - }; + } /** * Private helper function to update the internal dirty and pending changes @@ -469,13 +468,12 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { ChangeSet.prototype._performApplyAfterOnPropertyArray(pendingChanges, in_changeSet, this.getFullTypeid(true)); - var dirtyChanges = this._getDirtyChanges(); ChangeSet.prototype._performApplyAfterOnPropertyArray(dirtyChanges, in_changeSet, this.getFullTypeid(true)); this._setChanges(pendingChanges, dirtyChanges); - }; + } /** * Returns the pending changeset for this object @@ -483,7 +481,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ _getPendingChanges() { return (this._dirty && this._dirty.pending) || {}; - }; + } /** * Returns the dirty changeset for this object @@ -491,7 +489,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ _getDirtyChanges() { return (this._dirty && this._dirty.dirty) || {}; - }; + } /** * Sets the pending and dirty changesets @@ -532,7 +530,6 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { if (this._dirty) { if (this._dirty.dirty === undefined && this._dirty.pending === undefined) { - if (oldFlags === 0) { this._dirty = undefined; } else { @@ -544,7 +541,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } else if (oldFlags) { this._dirty = DIRTY_STATE_FLAGS_ARRAY[oldFlags]; } - }; + } /** * Sets the dirty flags for this property @@ -563,11 +560,10 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } else { this._dirty = DIRTY_STATE_FLAGS_ARRAY[in_flags]; } - } else { this._dirty = DIRTY_STATE_FLAGS_ARRAY[in_flags]; } - }; + } /** * Gets the dirty flags for this property @@ -579,7 +575,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } return this._dirty.flags; - }; + } /** * Inserts the content of a given array into the array property @@ -598,17 +594,17 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { throw new Error(MSG.IN_ARRAY_NOT_ARRAY + 'ArrayProperty.insertRange'); } - if (validationsEnabled.enabled) { - for (var i = 0; i < in_array.length; i++) { - if (in_array[i] instanceof BaseProperty) { - in_array[i]._validateInsertIn(this) - } - } - this._checkIsNotReadOnly(true); - } + if (validationsEnabled.enabled) { + for (var i = 0; i < in_array.length; i++) { + if (in_array[i] instanceof BaseProperty) { + in_array[i]._validateInsertIn(this); + } + } + this._checkIsNotReadOnly(true); + } this._insertRangeWithoutDirtying(in_offset, in_array); this._setDirty(); - }; + } /** * inserts the content of a given array, but doesn't dirty the property @@ -620,7 +616,9 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { * @private */ _insertRangeWithoutDirtying(in_offset, in_array, in_setParents) { - if (in_setParents === undefined) in_setParents = true; + if (in_setParents === undefined) { + in_setParents = true; + } if (in_offset < 0 || in_offset > this.length || !_.isNumber(in_offset)) { throw Error(MSG.START_OFFSET_INVALID + in_offset); } @@ -646,10 +644,10 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { // Insert entry into changesets var changeSet = { - 'insert': [[in_offset, this._serializeArray(in_array)]] + 'insert': [[in_offset, this._serializeArray(in_array)]], }; this._updateChanges(changeSet); - }; + } /** * Removes a given number of elements from the array property (or given number of letters from a StringProperty) @@ -679,7 +677,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { this._removeRangeWithoutDirtying(in_offset, in_deleteCount); this._setDirty(); return result; - }; + } /** * removes a given number of elements from the array property, and ensures, if this is not @@ -700,7 +698,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } this._dataArrayRemoveRange(in_offset, in_deleteCount); - }; + } /** * removes a given number of elements from the array property, but doesn't dirty the property @@ -714,10 +712,10 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { // Insert entry into changesets var changeSet = { - 'remove': [[in_offset, in_deleteCount]] + 'remove': [[in_offset, in_deleteCount]], }; this._updateChanges(changeSet); - }; + } /** * Sets the array properties elements to the content of the given array @@ -742,7 +740,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { this._checkIsNotReadOnly(true); this._setRangeWithoutDirtying(in_offset, in_array); this._setDirty(); - }; + } /** * sets the array properties elements to the content of the given array @@ -753,7 +751,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ _setRangeWithoutDirtying(in_offset, in_array) { this._modifyRangeWithoutDirtying(in_offset, in_array); - }; + } /** * sets the array properties elements to the content of the given array @@ -795,8 +793,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { changeSet['modify'] = changeArray; this._updateChanges(changeSet); } - }; - + } /** * Returns the name of all the sub-properties of this property. @@ -807,7 +804,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ getIds() { return Object.keys(this._dataArrayGetBuffer()); - }; + } /** * Checks whether a property or data exists at the given position. @@ -817,7 +814,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ has(in_position) { return this._dataArrayGetBuffer()[in_position] !== undefined; - }; + } /** * Gets the array element at a given index @@ -890,7 +887,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } return result; } - }; + } /** * Returns an object with all the nested values contained in this property @@ -918,14 +915,14 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { result.push(child.getValues()); } return result; - }; + } /** * @return {Number} the current length of the array */ getLength() { return this._dataArrayGetLength(); - }; + } /** * @inheritdoc @@ -1015,7 +1012,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { // Finally mark the property as dirty (we postponed this in the previous operations to prevent multiple triggering // of dirtying events) this._setDirty(in_reportToView); - }; + } /** * @inheritdoc @@ -1027,7 +1024,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { // Finally mark the property as dirty (we postponed this in the previous operations to prevent multiple triggering // of dirtying events) this._setDirty(false); - }; + } /** * Removes the dirtiness flag from this property @@ -1053,8 +1050,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } this._setChanges(pendingChanges, dirtyChanges); - }; - + } /** * Removes the dirtiness flag from this property and recursively from all of its children @@ -1070,8 +1066,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } // after all paths are clean, we are also clean! this._cleanDirty(in_dirtinessType); - }; - + } /** * Internal helper function that implements the deserialize algorithm for an array of named properties. @@ -1194,7 +1189,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { let elementsToInsert = targetArray.slice(lastPositionInTargetArray, startPointInTargetArray); changes.insert.push([ lastPositionInInitialArray, - deepCopy(elementsToInsert) + deepCopy(elementsToInsert), ]); var scope = this._getScope(); var insertedProperties = deserializeNonPrimitiveArrayElements(elementsToInsert, scope); @@ -1237,7 +1232,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { this._setDirty(in_reportToView); } return changes; - }; + } /** * Function to deserialize special primitive types. @@ -1249,7 +1244,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ _deserializeValue(in_serializedObj) { return in_serializedObj; - }; + } /** * Function to serialize special primitive types. @@ -1262,7 +1257,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { _serializeValue(in_obj) { // we have to convert the propertySet objects to changesets return in_obj._serialize(false, true); - }; + } /** * Function to serialize arrays of special primitive types. @@ -1285,7 +1280,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } } return result; - }; + } /** * Function to deserialize arrays of special primitive types. @@ -1297,8 +1292,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ _deserializeArray(in_serializedObj) { return in_serializedObj; - }; - + } /** * @inheritdoc @@ -1320,13 +1314,12 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { if (!in_serializedObj.insert || !in_serializedObj.insert[0]) { - // we've got an empty object, so we have to wipe everything we've got if (arrayLength > 0) { this._clearRange(0, arrayLength); this._setDirty(in_reportToView); var removeChangeSet = { - remove: [[0, arrayLength]] + remove: [[0, arrayLength]], }; this._updateChanges(removeChangeSet); return removeChangeSet; @@ -1345,7 +1338,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { // The changes we will report as result of this function var simpleChanges = { - insert: in_createChangeSet ? deepCopy(in_serializedObj.insert) : in_serializedObj.insert + insert: in_createChangeSet ? deepCopy(in_serializedObj.insert) : in_serializedObj.insert, }; if (arrayLength > 0) { simpleChanges.remove = [[0, arrayLength]]; @@ -1402,7 +1395,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { return simpleChanges; } - }; + } _getChangesetForCustomTypeArray(in_basePropertyChangeset, in_dirtinessType, @@ -1417,7 +1410,6 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { var currentArraySize = this._dataArrayGetLength(); var op, opStartIndex; while (!iterator.atEnd() || currentArrayIndex < currentArraySize) { - if (!iterator.atEnd()) { op = iterator.opDescription; opStartIndex = op.operation[0] + op.offset; @@ -1427,13 +1419,11 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { opStartIndex = Number.MAX_VALUE; } - if (currentArrayIndex < opStartIndex) { // not in the influence of an insert or remove // we have to check if the element was modified (since that is not tracked) if (this._dataArrayGetValue(currentArrayIndex)._isDirty(in_dirtinessType)) { - // check if we can combine modifies: var lastModify = undefined; if (result.modify && result.modify.length > 0) { @@ -1449,7 +1439,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { lastModify[1].push(this._dataArrayGetValue(currentArrayIndex).serialize( { 'dirtyOnly': true, 'includeRootTypeid': true, 'dirtinessType': in_dirtinessType, - 'includeReferencedRepositories': in_includeReferencedRepositories + 'includeReferencedRepositories': in_includeReferencedRepositories, })); } else { // begin new modify @@ -1460,7 +1450,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { [this._dataArrayGetValue(currentArrayIndex).serialize( { 'dirtyOnly': true, 'includeRootTypeid': true, 'dirtinessType': in_dirtinessType, - 'includeReferencedRepositories': in_includeReferencedRepositories + 'includeReferencedRepositories': in_includeReferencedRepositories, })]]); } currentArrayIndex++; @@ -1471,12 +1461,11 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { this._dataArrayGetValue(currentArrayIndex).serialize( { 'dirtyOnly': true, 'includeRootTypeid': true, 'dirtinessType': in_dirtinessType, - 'includeReferencedRepositories': in_includeReferencedRepositories - }) + 'includeReferencedRepositories': in_includeReferencedRepositories, + }), ); currentArrayIndex++; } - } else { currentArrayIndex++; } @@ -1499,7 +1488,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { newInsert[1].push(this._dataArrayGetValue(opStartIndex + j).serialize( { 'dirtyOnly': false, 'includeRootTypeid': true, 'dirtinessType': in_dirtinessType, - 'includeReferencedRepositories': in_includeReferencedRepositories + 'includeReferencedRepositories': in_includeReferencedRepositories, })); } if (!result.insert) { @@ -1516,7 +1505,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } } return result; - }; + } /** * Serialize the property @@ -1577,7 +1566,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } return result; } - }; + } /** * Repeatedly calls back the given function with human-readable string @@ -1588,7 +1577,6 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { * @param {function} printFct - Function to call for printing each property */ _prettyPrint(indent, externalId, printFct) { - printFct(indent + externalId + this.getId() + ' (Array of ' + this.getTypeid() + '): ['); if (!this._isPrimitive) { this._prettyPrintChildren(indent, printFct); @@ -1605,7 +1593,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } } printFct(indent + ']'); - }; + } /** * Repeatedly calls back the given function with human-readable string @@ -1620,7 +1608,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { this.get(ids[i], { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER }) ._prettyPrint(indent, ids[i] + ': ', printFct); } - }; + } /** * Return a JSON representation of the array and its items. @@ -1633,14 +1621,14 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { context: this._context, typeid: this.getTypeid(), isConstant: this._isConstant, - value: [] + value: [], }; if (!this._isPrimitive) { var ids = this.getIds(); for (var i = 0; i < ids.length; i++) { json.value.push( - this.get(ids[i], { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER })._toJson() + this.get(ids[i], { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER })._toJson(), ); } } else { @@ -1648,7 +1636,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } return json; - }; + } /** * Returns the full property type identifier for the ChangeSet including the array type id, if not @@ -1662,7 +1650,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } else { return TypeIdHelper.createSerializationTypeId(this._typeid, 'array'); } - }; + } /** * Creates and initializes the data array @@ -1677,7 +1665,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { element._setParent(this); this._dataArraySetValue(i, element); } - }; + } /** * Returns the length of the data array @@ -1685,7 +1673,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ _dataArrayGetLength() { return this._dataArrayRef.length; - }; + } /** * Returns the data array's internal buffer @@ -1693,7 +1681,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ _dataArrayGetBuffer() { return this._dataArrayRef.getBuffer(); - }; + } /** * Returns an entry from the data array @@ -1703,7 +1691,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ _dataArrayGetValue(in_index) { return this._dataArrayRef.getValue(in_index); - }; + } /** * Sets an entry in the data array @@ -1712,7 +1700,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ _dataArraySetValue(in_index, in_value) { this._dataArrayRef.setValue(in_index, in_value); - }; + } /** * Set the array to the given new array @@ -1720,7 +1708,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ _dataArrayDeserialize(in_newArray) { this._dataArrayRef.deserialize(in_newArray); - }; + } /** * Inserts a range into the data array @@ -1729,7 +1717,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ _dataArrayInsertRange(in_position, in_range) { this._dataArrayRef.insertRange(in_position, in_range); - }; + } /** * Removes a range from the data array @@ -1738,7 +1726,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ _dataArrayRemoveRange(in_position, in_length) { this._dataArrayRef.removeRange(in_position, in_length); - }; + } /** * Overwrites a range in the data array @@ -1747,7 +1735,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { */ _dataArraySetRange(in_position, in_range) { this._dataArrayRef.set(in_position, in_range); - }; + } /** * Get the scope to which this property belongs to. @@ -1764,7 +1752,7 @@ export class ArrayProperty extends AbstractStaticCollectionProperty { } else { return this._scope; } - }; + } /** * returns the length of the current array property diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/baseProperty.ts b/experimental/PropertyDDS/packages/property-properties/src/properties/baseProperty.ts index 7ee361e072b4..38dba168a33e 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/baseProperty.ts +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/baseProperty.ts @@ -8,10 +8,9 @@ import { ChangeSet, PathHelper, SerializedChangeSet, - TypeIdHelper + TypeIdHelper, } from '@fluid-experimental/property-changeset'; -import { constants } from '@fluid-experimental/property-common'; -import { ConsoleUtils } from '@fluid-experimental/property-common'; +import { ConsoleUtils, constants } from '@fluid-experimental/property-common'; import { LazyLoadedProperties as Property } from './lazyLoadedProperties'; const { MSG, PROPERTY_PATH_DELIMITER } = constants; @@ -26,7 +25,7 @@ enum REFERENCE_RESOLUTION { /** If a reference is the last entry during the path resolution, it will not automatically be resolved */ NO_LEAFS, /** References are never automatically resolved */ - NEVER + NEVER, } /** @@ -38,8 +37,8 @@ enum MODIFIED_STATE_FLAGS { /** The property is marked as changed in the currently pending ChangeSet */ PENDING_CHANGE, /** The property has been modified and the result has not yet been reported to the application for scene updates */ - DIRTY -}; + DIRTY, +} /** * Token Types @@ -52,10 +51,9 @@ const PATH_TOKENS = { /** A * that indicates a dereferencing operation */ // note: reversed! REF: { 'token': 'REF' }, /** A ../ that indicates one step above the current path */ - UP: { 'token': 'UP' } + UP: { 'token': 'UP' }, }; - interface IBasePropertyParams { /** id of the property */ id?: string, @@ -66,11 +64,11 @@ interface IBasePropertyParams { /** The type of property this template represents i.e. single, array, map, set. */ context: string, - //TODO: UNUSED PARAMETER ?? + // TODO: UNUSED PARAMETER ?? /** List of property templates that are used to define children properties */ properties: BaseProperty[], - //TODO: UNUSED PARAMETER ?? + // TODO: UNUSED PARAMETER ?? /** List of property template typeids that this PropertyTemplate inherits from */ inherits: string[] } @@ -142,7 +140,7 @@ export abstract class BaseProperty { if (!this._noDirtyInBase) { this._dirty = MODIFIED_STATE_FLAGS.CLEAN; } - }; + } static MODIFIED_STATE_FLAGS = MODIFIED_STATE_FLAGS; static REFERENCE_RESOLUTION = REFERENCE_RESOLUTION; @@ -153,14 +151,14 @@ export abstract class BaseProperty { */ getTypeid(): string { return this._typeid; - }; + } /** * @returns The context of this property */ getContext(): string { return this._context; - }; + } /** * Get the scope to which this property belongs to. @@ -173,7 +171,7 @@ export abstract class BaseProperty { } else { return undefined; } - }; + } /** * Returns the full property type identifier for the ChangeSet including the enum type id @@ -183,7 +181,7 @@ export abstract class BaseProperty { */ getFullTypeid(in_hideCollection = false): string { return this._typeid; - }; + } /** * Updates the parent for the property @@ -199,7 +197,7 @@ export abstract class BaseProperty { if (this._parent && this._isDirty() && !this._parent._isDirty()) { this._parent._setDirty(false, this); } - }; + } /** * Is this property the root of the property set tree? @@ -210,7 +208,7 @@ export abstract class BaseProperty { // This checks, whether this is the root of a CheckOutView // (all other properties should have a parent property) return this._parent === undefined; - }; + } /** * Is this property the ancestor of in_otherProperty? @@ -230,7 +228,7 @@ export abstract class BaseProperty { } } return false; - }; + } /** * Is this property the descendant of in_otherProperty? @@ -242,7 +240,7 @@ export abstract class BaseProperty { isDescendantOf(in_otherProperty: BaseProperty): boolean { ConsoleUtils.assert(in_otherProperty, MSG.MISSING_IN_OTHERPROP); return in_otherProperty.isAncestorOf(this); - }; + } /** * Is this property a leaf node with regard to flattening? @@ -253,7 +251,7 @@ export abstract class BaseProperty { */ _isFlattenLeaf(): boolean { return false; - }; + } /** * Get the parent of this property @@ -262,7 +260,7 @@ export abstract class BaseProperty { */ getParent(): BaseProperty | undefined { return this._parent; - }; + } /** * checks whether the property is dynamic (only properties inherting from NodeProperty are) @@ -270,7 +268,7 @@ export abstract class BaseProperty { */ isDynamic() { return false; - }; + } /** * Sets the property as dirty and/or pending. This will add one or both flags if not already set and will @@ -286,7 +284,7 @@ export abstract class BaseProperty { _setDirty( in_reportToView = true, in_callingChild: BaseProperty = undefined, - in_flags: MODIFIED_STATE_FLAGS = MODIFIED_STATE_FLAGS.DIRTY | MODIFIED_STATE_FLAGS.PENDING_CHANGE + in_flags: MODIFIED_STATE_FLAGS = MODIFIED_STATE_FLAGS.DIRTY | MODIFIED_STATE_FLAGS.PENDING_CHANGE, ) { if (in_flags === undefined) { in_flags = MODIFIED_STATE_FLAGS.DIRTY | MODIFIED_STATE_FLAGS.PENDING_CHANGE; @@ -309,7 +307,7 @@ export abstract class BaseProperty { if (reportToView) { this._reportDirtinessToView(); } - }; + } /** * Sets the dirty flags for this property @@ -317,7 +315,7 @@ export abstract class BaseProperty { */ _setDirtyFlags(in_flags: MODIFIED_STATE_FLAGS) { this._dirty = in_flags; - }; + } /** * Gets the dirty flags for this property @@ -325,7 +323,7 @@ export abstract class BaseProperty { */ _getDirtyFlags(): MODIFIED_STATE_FLAGS { return this._dirty; - }; + } /** * Helper function, which reports the fact that a property has been dirtied to the checkout view @@ -351,7 +349,7 @@ export abstract class BaseProperty { ) { currentNode._tree._reportDirtinessToView(); } - }; + } /** * Modifies the property according to the given changeset @@ -366,7 +364,7 @@ export abstract class BaseProperty { // We just forward the call to the internal function this._applyChangeset(in_changeSet, true); - }; + } /** * Modifies the property according to the given changeset @@ -403,7 +401,7 @@ export abstract class BaseProperty { if (in_reportToView) { this._reportDirtinessToView(); } - }; + } /** * Re-apply dirty flags from changesets @@ -420,7 +418,6 @@ export abstract class BaseProperty { // changeset, sometimes only one in the other changeset, sometimes one in both. const typeids = _.keys(in_pendingChangeSet).concat(_.keys(in_dirtyChangeSet)); for (const typeid of typeids) { - if (ChangeSet.isReservedKeyword(typeid)) { continue; // Ignore the special keys } @@ -429,7 +426,6 @@ export abstract class BaseProperty { const paths = _.keys(pendingChangeSet).concat(_.keys(dirtyChangeSet)); for (const path of paths) { - let property = this.resolvePath(path); if (property) { property._reapplyDirtyFlags( @@ -444,7 +440,7 @@ export abstract class BaseProperty { protected resolvePath(path: string, params?: any): BaseProperty { throw new Error("Method not implemented."); - }; + } /** * Removes the dirtiness flag from this property @@ -455,8 +451,7 @@ export abstract class BaseProperty { _cleanDirty(in_flags) { this._setDirtyFlags(in_flags === undefined ? MODIFIED_STATE_FLAGS.CLEAN : (this._getDirtyFlags() & ~in_flags)); - }; - + } /** * Removes the dirtiness flag from this property and recursively from all of its children @@ -469,7 +464,7 @@ export abstract class BaseProperty { for (const dirtyChild of dirtyChildren) { const child = this.get( dirtyChild, - { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER } + { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER }, ); child.cleanDirty(in_flags); child._cleanDirty(in_flags); @@ -477,7 +472,7 @@ export abstract class BaseProperty { // after all paths are clean, we are also clean! this._cleanDirty(in_flags); - }; + } /** * Indicates that the property has been modified and a corresponding modified call has not yet been sent to the @@ -488,7 +483,7 @@ export abstract class BaseProperty { */ _isDirty(in_dirtinessType: MODIFIED_STATE_FLAGS = MODIFIED_STATE_FLAGS.DIRTY): boolean { return !!(this._getDirtyFlags() & in_dirtinessType); - }; + } /** * Indicates that the property has been modified and a corresponding modified call has not yet been sent to the @@ -498,7 +493,7 @@ export abstract class BaseProperty { */ isDirty(): boolean { return this._isDirty(); - }; + } /** * The property has pending changes in the current ChangeSet. @@ -506,7 +501,7 @@ export abstract class BaseProperty { */ hasPendingChanges(): boolean { return this._isDirty(MODIFIED_STATE_FLAGS.PENDING_CHANGE); - }; + } /** * Returns the ChangeSet of all sub-properties @@ -516,7 +511,7 @@ export abstract class BaseProperty { getPendingChanges(): ChangeSet { var serialized = this._serialize(true, false, BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE); return new ChangeSet(serialized); - }; + } /** * Get the id of this property @@ -525,7 +520,7 @@ export abstract class BaseProperty { */ getId(): string | undefined { return this._id; - }; + } /** * Sets the checkedOutRepositoryInfo. @@ -534,7 +529,7 @@ export abstract class BaseProperty { */ _setCheckoutView(value) { this._checkoutView = value; - }; + } /** * Returns the checkoutView @@ -543,7 +538,7 @@ export abstract class BaseProperty { _getCheckoutView() { let checkedOutRepositoryInfo = this._getCheckedOutRepositoryInfo(); return checkedOutRepositoryInfo ? checkedOutRepositoryInfo.getCheckoutView() : undefined; - }; + } /** * Returns the checkedOutRepositoryInfo. @@ -556,7 +551,7 @@ export abstract class BaseProperty { } else { return this.getRoot() ? this.getRoot()._getCheckedOutRepositoryInfo() : undefined; } - }; + } /** * Returns the Workspace @@ -565,7 +560,7 @@ export abstract class BaseProperty { getWorkspace() { const root = this.getRoot(); return root ? root._tree : undefined; - }; + } /** * Returns the path segment for a child @@ -576,7 +571,7 @@ export abstract class BaseProperty { */ _getPathSegmentForChildNode(in_childNode: BaseProperty): string { return PROPERTY_PATH_DELIMITER + PathHelper.quotePathSegmentIfNeeded(in_childNode.getId()); - }; + } /** * Resolves a direct child node based on the given path segment @@ -594,7 +589,7 @@ export abstract class BaseProperty { } return this.get(in_segment, { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER }); - }; + } /** * Set the id of this property @@ -619,7 +614,7 @@ export abstract class BaseProperty { this._setDirty(); return in_id; - }; + } /** * Return a clone of this property @@ -628,7 +623,7 @@ export abstract class BaseProperty { clone(): BaseProperty { const PropertyFactory = Property.PropertyFactory; var clone = PropertyFactory._createProperty( - this.getFullTypeid(), null, undefined, this._getScope(), true + this.getFullTypeid(), null, undefined, this._getScope(), true, ); // TODO: this is not very efficient. Clone should be overriden @@ -636,10 +631,10 @@ export abstract class BaseProperty { clone.deserialize(this._serialize()); clone.cleanDirty( BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE | - BaseProperty.MODIFIED_STATE_FLAGS.DIRTY + BaseProperty.MODIFIED_STATE_FLAGS.DIRTY, ); return clone; - }; + } /** * Returns true if the property is a primitive type @@ -647,7 +642,7 @@ export abstract class BaseProperty { */ isPrimitiveType() { return TypeIdHelper.isPrimitiveType(this._typeid); - }; + } /** * Get a flattened, tree like representation of this object and all of it's @@ -662,7 +657,7 @@ export abstract class BaseProperty { */ private _flatten(): object { return { propertyNode: this }; - }; + } /** * Repeatedly calls back the given function with human-readable string representations @@ -675,7 +670,7 @@ export abstract class BaseProperty { printFct = console.log; } this._prettyPrint('', '', printFct); - }; + } /** * Return a JSON representation of the properties and its children. @@ -688,18 +683,18 @@ export abstract class BaseProperty { context: this._context, typeid: this.getTypeid(), isConstant: this._isConstant, - value: [] + value: [], }; var ids = this.getIds(); for (const id of ids) { json.value.push( - this.get(id, { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER })._toJson() + this.get(id, { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER })._toJson(), ); } return json; - }; + } getIds(): string[] { return []; @@ -726,7 +721,7 @@ export abstract class BaseProperty { } printFct(indent + externalId + this.getId() + ' (' + context + this.getTypeid() + '):'); this._prettyPrintChildren(indent, printFct); - }; + } /** * Repeatedly calls back the given function with human-readable string @@ -740,7 +735,7 @@ export abstract class BaseProperty { for (var i = 0; i < ids.length; i++) { this.get(ids[i], { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER })._prettyPrint(indent, '', printFct); } - }; + } /** * Returns the possible paths from the given from_property to this property. If multiple paths @@ -796,7 +791,7 @@ export abstract class BaseProperty { return paths; } return []; - }; + } /** * Returns the possible paths from the given in_fromProperty to this property. If no direct paths @@ -829,7 +824,7 @@ export abstract class BaseProperty { } else { return undefined; } - }; + } /** * Returns the path from the given in_fromProperty to this property if a direct path @@ -873,7 +868,7 @@ export abstract class BaseProperty { } else { return undefined; } - }; + } /** * Returns the possible paths from the given in_fromProperty to this property. @@ -896,7 +891,7 @@ export abstract class BaseProperty { return [this._getIndirectPath(in_fromProperty)]; } } - }; + } /** * Returns the path from the given fron_property to this node if such a path exists. @@ -926,7 +921,7 @@ export abstract class BaseProperty { ' and ' + this.getAbsolutePath()); } return paths[0]; - }; + } /** * Returns the path from the root of the workspace to this node @@ -985,7 +980,7 @@ export abstract class BaseProperty { absolutePath = '/' + absolutePath; return absolutePath; - }; + } /** * Traverses the property hierarchy upwards until the a node without parent is reached @@ -1008,7 +1003,7 @@ export abstract class BaseProperty { } return undefined; - }; + } /** * @type {string} Constant to stop the traversal in traverseUp and traverseDown functions @@ -1025,7 +1020,7 @@ export abstract class BaseProperty { */ private _getDirtyChildren(in_flags: MODIFIED_STATE_FLAGS): string[] { return []; - }; + } /** * Returns the root of the property hierarchy @@ -1033,7 +1028,7 @@ export abstract class BaseProperty { */ getRoot(): BaseProperty { return this._parent ? this._parent.getRoot() : this; - }; + } /** * Traverses all children in the child hierarchy @@ -1047,7 +1042,7 @@ export abstract class BaseProperty { */ _traverse(in_callback: Function, in_pathFromTraversalStart: string): string | undefined { return undefined; - }; + } /** * Deserialize takes a currently existing property and sets it to the hierarchy described in the normalized @@ -1072,11 +1067,11 @@ export abstract class BaseProperty { in_serializedObj: SerializedChangeSet, in_filteringOptions = {}, in_createChangeSet = true, - in_reportToView = false + in_reportToView = false, ): SerializedChangeSet { this._checkIsNotReadOnly(false); return this._deserialize(in_serializedObj, in_reportToView, in_filteringOptions, in_createChangeSet); - }; + } /** * Sets the property to the state in the given normalized changeset @@ -1099,7 +1094,7 @@ export abstract class BaseProperty { in_createChangeSet = true, ): SerializedChangeSet { return {}; - }; + } /** * Serialize the property into a changeSet @@ -1119,11 +1114,10 @@ export abstract class BaseProperty { in_dirtyOnly: boolean = false, in_includeRootTypeid: boolean = false, in_dirtinessType: MODIFIED_STATE_FLAGS = MODIFIED_STATE_FLAGS.PENDING_CHANGE, - in_includeReferencedRepositories: boolean = false + in_includeReferencedRepositories: boolean = false, ): object { return {}; - }; - + } /** * Serialize the property @@ -1137,10 +1131,12 @@ export abstract class BaseProperty { dirtyOnly: false, includeRootTypeid: false, dirtinessType: MODIFIED_STATE_FLAGS.PENDING_CHANGE, - includeReferencedRepositories: false + includeReferencedRepositories: false, }; if (in_options !== undefined) { - if (typeof in_options !== 'object') throw new Error(MSG.SERIALIZE_TAKES_OBJECT); + if (typeof in_options !== 'object') { + throw new Error(MSG.SERIALIZE_TAKES_OBJECT); + } Object.assign(opts, in_options); } @@ -1148,9 +1144,9 @@ export abstract class BaseProperty { opts.dirtyOnly, opts.includeRootTypeid, opts.dirtinessType, - opts.includeReferencedRepositories + opts.includeReferencedRepositories, ); - }; + } /** * Indicate that all static members have been added to the property @@ -1158,7 +1154,7 @@ export abstract class BaseProperty { * This function is invoked by the PropertyFactory once all static members have been added to the template * @protected */ - _signalAllStaticMembersHaveBeenAdded() { }; + _signalAllStaticMembersHaveBeenAdded() { } /** * Tests whether this property may be modified @@ -1177,7 +1173,7 @@ export abstract class BaseProperty { throw new Error(MSG.MODIFICATION_OF_REFERENCED_PROPERTY); } } - }; + } /** * Set a property and its children as constants (readonly properties) @@ -1195,7 +1191,7 @@ export abstract class BaseProperty { traverseDown(arg0: (prop: any) => void) { throw new Error("Method not implemented."); - }; + } /** * Unsets a property and its children as constants @@ -1213,7 +1209,7 @@ export abstract class BaseProperty { delete prop._isConstant; }); } - }; + } /** * Dirties this node and all of its children @@ -1232,7 +1228,7 @@ export abstract class BaseProperty { if (in_reportToView) { this._reportDirtinessToView(); } - }; + } /** * Determines whether a property can be inserted as a child of another property @@ -1242,7 +1238,6 @@ export abstract class BaseProperty { * @throws if the property can not be inserted */ _validateInsertIn(in_targetParent: BaseProperty) { - // A root? if (this._getCheckedOutRepositoryInfo() !== undefined) { throw new Error(MSG.INSERTED_ROOT_ENTRY); @@ -1261,7 +1256,7 @@ export abstract class BaseProperty { if (this._parent !== undefined || this._getCheckoutView() !== undefined) { throw new Error(MSG.INSERTED_ENTRY_WITH_PARENT); } - }; + } /** * TODO: Remove it later. Kept not to modify tests @@ -1288,7 +1283,7 @@ export abstract class BaseProperty { // We know that part of the property is covered, if we don't find any actual children not covered // by the paths it's because we're fully covered. if (this.isPrimitiveType()) { - const childrenIds = this.getContext() === 'single' ? [] : this.getIds() + const childrenIds = this.getContext() === 'single' ? [] : this.getIds(); for (const childId of childrenIds) { const childPath = PathHelper.getChildAbsolutePathCanonical(in_basePath, childId); if (PathHelper.getPathCoverage(childPath, coverage.pathList).coverageExtent === PathHelper.CoverageExtent.UNCOVERED) { @@ -1310,12 +1305,11 @@ export abstract class BaseProperty { } return false; - }; + } get _properties() { return this._flatten(); } - } (BaseProperty as any).prototype._isConstant = false; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/boolProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/boolProperty.js index 0521d57e3daa..d6aaa43f4763 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/boolProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/boolProperty.js @@ -14,7 +14,6 @@ const { _castFunctors } = require('./primitiveTypeCasts'); * A primitive property for a boolean value */ export class BoolProperty extends ValueProperty { - /** * @param in_params - the parameters */ @@ -22,7 +21,7 @@ export class BoolProperty extends ValueProperty { super(in_params); // default for this property type is 'false' this._data = false; - }; + } } BoolProperty.prototype._typeid = 'Bool'; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/containerProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/containerProperty.js index 7fbf5e0d5395..542bae49956b 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/containerProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/containerProperty.js @@ -6,13 +6,13 @@ /** * @fileoverview This file contains the implementation of the ContainerProperty class */ -const _ = require('underscore'); -const { BaseProperty } = require('./baseProperty'); -const { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty'); const { MSG } = require('@fluid-experimental/property-common').constants; const { ConsoleUtils } = require('@fluid-experimental/property-common'); -const { IndexedCollectionBaseProperty } = require('./indexedCollectionBaseProperty'); +const _ = require('underscore'); const { validationsEnabled } = require('../enableValidations'); +const { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty'); +const { BaseProperty } = require('./baseProperty'); +const { IndexedCollectionBaseProperty } = require('./indexedCollectionBaseProperty'); /** * A property object that allows to add child properties dynamically. @@ -24,14 +24,13 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { * @protected */ constructor(in_params) { - super( in_params ); + super(in_params); if (in_params.optionalChildren) { this._optionalChildren = {}; this._dynamicChildren = {}; } - - }; + } /** * Returns the name of all the sub-properties of this property. @@ -39,7 +38,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { */ _getIds() { return AbstractStaticCollectionProperty.prototype._getIds.call(this).concat(Object.keys(this._dynamicChildren)); - }; + } /** * Returns the sub-property having the given name in this property. @@ -50,7 +49,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { */ _get(in_id) { return AbstractStaticCollectionProperty.prototype._get.call(this, in_id) || this._dynamicChildren[in_id]; - }; + } /** * Adds an optional child to list of possible optional children. @@ -64,7 +63,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { this._dynamicChildren = {}; } this._optionalChildren[in_id] = in_typeid; - }; + } /** * Appends a property @@ -106,7 +105,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { // Add the child property to the dynamic properties this._insert(in_property.getId(), in_property, true); - }; + } /** * Validates if inserting the property is valid. @@ -126,7 +125,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { throw new Error(MSG.MISMATCHING_PROPERTY_TYPEID + this._optionalChildren[in_id] + ' instead it\'s: ' + in_property.getTypeid()); } - }; + } /** * @override @@ -142,7 +141,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { return undefined; } } - }; + } /** * Removes the given property @@ -166,7 +165,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { this._removeByKey(id); return returnValue; - }; + } /** * Validates if removing a property with specified id is valid. @@ -184,7 +183,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { throw new Error((MSG.REMOVING_NON_EXISTING_KEY + in_id)); } } - }; + } /** * Removes all dynamic children @@ -193,7 +192,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { clear() { this._checkIsNotReadOnly(true); _.each(this._dynamicChildren, this.remove.bind(this)); - }; + } /** * Inserts a property into the collection @@ -219,7 +218,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { if (in_reportToView) { this._reportDirtinessToView(); } - }; + } /** * Removes an entry with the given key @@ -238,7 +237,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { } else { console.error(MSG.REMOVING_NON_EXISTING_KEY + in_key); } - }; + } /** * Stores the information to which CheckedOutRepositoryInfo object this root property belongs. @@ -250,7 +249,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { */ _setCheckedOutRepositoryInfo(in_checkedOutRepositoryInfo) { this._checkedOutRepositoryInfo = in_checkedOutRepositoryInfo; - }; + } /** * Gets the information to which CheckedOutRepositoryInfo object this root property belongs. @@ -262,7 +261,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { */ _getCheckedOutRepositoryInfo() { return this._checkedOutRepositoryInfo; - }; + } /** * Returns the name of all the static sub-properties of this property. @@ -271,7 +270,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { */ getStaticIds() { return Object.keys(this._staticChildren); - }; + } /** * Returns the name of all the dynamic sub-properties of this property. @@ -280,7 +279,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { */ getDynamicIds() { return Object.keys(this._dynamicChildren); - }; + } /** * Returns an Object with all the dynamic children of this node property. @@ -293,7 +292,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { */ _getDynamicChildrenReadOnly() { return this._dynamicChildren; - }; + } /** * Given an object that mirrors a PSet Template, assign the properties @@ -321,8 +320,7 @@ export class ContainerProperty extends IndexedCollectionBaseProperty { } else { ContainerProperty.prototype._setValues.call(this, in_properties, false, false); } - }; - + } } ContainerProperty.prototype._typeid = 'ContainerProperty'; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/enumArrayProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/enumArrayProperty.js index d9ab0af4fab1..5524ac8fb304 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/enumArrayProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/enumArrayProperty.js @@ -2,11 +2,11 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -const _ = require('lodash'); -const { ValueArrayProperty } = require('./valueArrayProperty'); const { MSG } = require('@fluid-experimental/property-common').constants; const { TypeIdHelper } = require('@fluid-experimental/property-changeset'); const { BaseDataArray } = require('@fluid-experimental/property-common'); +const _ = require('lodash'); +const { ValueArrayProperty } = require('./valueArrayProperty'); /** * This class is a specialized version of the ArrayProperty for enums. @@ -32,7 +32,7 @@ export class EnumArrayProperty extends ValueArrayProperty { // dictonary [value->enum] and [enum->value] to efficiently lookup // values/enums for the property. this._enumDictionary = in_params._enumDictionary; - }; + } /** * Since an enum can be identified by its value and its enum string, @@ -56,7 +56,7 @@ export class EnumArrayProperty extends ValueArrayProperty { return in_value; } } - }; + } /** * inserts the content of a given array into the array property @@ -77,11 +77,11 @@ export class EnumArrayProperty extends ValueArrayProperty { var internalValueArray = []; var that = this; - _.each(in_array, function (element) { + _.each(in_array, function(element) { internalValueArray.push(that._convertEnumToInternalValue(element)); }); ValueArrayProperty.prototype.insertRange.call(this, in_offset, internalValueArray); - }; + } /** * Sets the content of an enum in an enum array @@ -95,7 +95,7 @@ export class EnumArrayProperty extends ValueArrayProperty { throw new Error(MSG.VALUE_STRING_OR_NUMBER + in_value); } this.setRange(in_index, [in_value]); - }; + } /** * Sets the content of an enum in an enum array. Alternative syntax to .set() @@ -106,7 +106,7 @@ export class EnumArrayProperty extends ValueArrayProperty { */ setEnumByString(in_index, in_value) { this.set(in_index, in_value); - }; + } /** * sets the array properties elements to the content of the given array @@ -127,11 +127,11 @@ export class EnumArrayProperty extends ValueArrayProperty { var internalValueArray = []; var that = this; - _.each(in_array, function (element) { + _.each(in_array, function(element) { internalValueArray.push(that._convertEnumToInternalValue(element)); }); ValueArrayProperty.prototype.setRange.call(this, in_offset, internalValueArray); - }; + } /** * get the array element at a given index @@ -147,7 +147,7 @@ export class EnumArrayProperty extends ValueArrayProperty { } else { return resultEntry.id; } - }; + } /** * get an array of the enum strings starting at a given index @@ -170,7 +170,7 @@ export class EnumArrayProperty extends ValueArrayProperty { result.push(this.getEnumString(i + in_offset)); } return result; - }; + } /** * Returns the full property type identifier for the ChangeSet including the enum type id @@ -183,7 +183,7 @@ export class EnumArrayProperty extends ValueArrayProperty { } else { return TypeIdHelper.createSerializationTypeId(this._typeid, 'array', true); } - }; + } /** * @inheritdoc @@ -195,7 +195,7 @@ export class EnumArrayProperty extends ValueArrayProperty { result.push(child); } return result; - }; + } /** * Creates and initializes the data array @@ -203,7 +203,7 @@ export class EnumArrayProperty extends ValueArrayProperty { */ _dataArrayCreate(in_length) { this._dataArrayRef = new BaseDataArray(Int32Array, in_length); - }; + } /** * let the user to query all valid entries of an enum array property @@ -211,7 +211,6 @@ export class EnumArrayProperty extends ValueArrayProperty { */ getValidEnumList() { return this._enumDictionary.enumEntriesById; - }; - + } } EnumArrayProperty.prototype._typeid = 'Enum'; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/enumProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/enumProperty.js index 90a5719f55ff..46c9cf87d2ec 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/enumProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/enumProperty.js @@ -6,19 +6,18 @@ * @fileoverview Definition of the EnumProperty classes */ +const { TypeIdHelper } = require('@fluid-experimental/property-changeset'); +const { MSG } = require('@fluid-experimental/property-common').constants; +const { ConsoleUtils } = require('@fluid-experimental/property-common'); const _ = require('lodash'); const { Int32Property } = require('./intProperties'); const { _castFunctors } = require('./primitiveTypeCasts'); const { ValueProperty } = require('./valueProperty'); -const { TypeIdHelper } = require('@fluid-experimental/property-changeset'); -const { MSG } = require('@fluid-experimental/property-common').constants; -const { ConsoleUtils } = require('@fluid-experimental/property-common'); /** * A primitive property for enums. */ export class EnumProperty extends Int32Property { - /** * @param {Object=} in_params - the parameters * @constructor @@ -35,7 +34,7 @@ export class EnumProperty extends Int32Property { this._enumDictionary = in_params._enumDictionary; // default for this property type is '0' if it exists to keep backward compatibility this._data = this._enumDictionary ? this._enumDictionary.defaultValue : 0; - }; + } /** * Evaluates enum properties as primitives. @@ -43,7 +42,7 @@ export class EnumProperty extends Int32Property { */ isPrimitiveType() { return true; - }; + } /** * Returns the current enum string @@ -57,7 +56,7 @@ export class EnumProperty extends Int32Property { } else { return resultEntry.id; } - }; + } /** * Sets the (internal, integer) value of the property @@ -79,7 +78,7 @@ export class EnumProperty extends Int32Property { } else { ValueProperty.prototype.setValue.call(this, in_value); } - }; + } /** * Sets the property by an enum string @@ -97,7 +96,7 @@ export class EnumProperty extends Int32Property { var internalValue = internalEnum.value; this.setValue(internalValue); } - }; + } /** * Returns the full property type identifier for the ChangeSet including the enum type id @@ -107,7 +106,7 @@ export class EnumProperty extends Int32Property { */ getFullTypeid(in_hideCollection = false) { return TypeIdHelper.createSerializationTypeId(this._typeid, 'single', true); - }; + } /** * let the user to query all valid entries of an enum @@ -115,7 +114,7 @@ export class EnumProperty extends Int32Property { */ getValidEnumList() { return this._enumDictionary.enumEntriesById; - }; + } } EnumProperty.prototype._typeid = 'Enum'; EnumProperty.prototype._castFunctor = _castFunctors.Int32; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/floatProperties.js b/experimental/PropertyDDS/packages/property-properties/src/properties/floatProperties.js index 23f1de14bd27..6d21a8e0d63b 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/floatProperties.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/floatProperties.js @@ -26,7 +26,7 @@ export class Float32Property extends ValueProperty { // default for this property type is '0' this._data = 0; - }; + } } Float32Property.prototype._castFunctor = _castFunctors.Float32; Float32Property.prototype._typeid = 'Float32'; @@ -48,7 +48,7 @@ export class Float64Property extends ValueProperty { super(in_params); // default for this property type is '0' this._data = 0; - }; + } } Float64Property.prototype._castFunctor = _castFunctors.Float64; Float64Property.prototype._typeid = 'Float64'; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/index.ts b/experimental/PropertyDDS/packages/property-properties/src/properties/index.ts index ba43e106c29c..b330c4797812 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/index.ts +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/index.ts @@ -5,58 +5,68 @@ import { ArrayProperty } from './arrayProperty'; import { BaseProperty } from './baseProperty'; -import { BoolArrayProperty } from './valueArrayProperty'; -import { BoolMapProperty } from './valueMapProperty'; import { BoolProperty } from './boolProperty'; import { ContainerProperty } from './containerProperty'; import { EnumArrayProperty } from './enumArrayProperty'; import { EnumProperty } from './enumProperty'; -import { Float32ArrayProperty } from './valueArrayProperty'; -import { Float32MapProperty } from './valueMapProperty'; -import { Float32Property } from './floatProperties'; -import { Float64ArrayProperty } from './valueArrayProperty'; -import { Float64MapProperty } from './valueMapProperty'; -import { Float64Property } from './floatProperties'; +import { + Float32Property, + Float64Property, +} from './floatProperties'; import { IndexedCollectionBaseProperty } from './indexedCollectionBaseProperty'; -import { Int16ArrayProperty } from './valueArrayProperty'; -import { Int16MapProperty } from './valueMapProperty'; -import { Int16Property } from './intProperties'; -import { Int32ArrayProperty } from './valueArrayProperty'; -import { Int32MapProperty } from './valueMapProperty'; -import { Int32Property } from './intProperties'; -import { Int64ArrayProperty } from './valueArrayProperty'; -import { Int64MapProperty } from './valueMapProperty'; -import { Int64Property } from './intProperties'; -import { Int8ArrayProperty } from './valueArrayProperty'; -import { Int8MapProperty } from './valueMapProperty'; -import { Int8Property } from './intProperties'; +import { + Int16Property, + Int32Property, + Int64Property, + Int8Property, + Uint64Property, +} from './intProperties'; import { MapProperty } from './mapProperty'; import { NamedNodeProperty } from './namedNodeProperty'; import { NamedProperty } from './namedProperty'; import { NodeProperty } from './nodeProperty'; +import { _castFunctors } from './primitiveTypeCasts'; import { ReferenceArrayProperty } from './referenceArrayProperty'; import { ReferenceMapProperty } from './referenceMapProperty'; import { ReferenceProperty } from './referenceProperty'; import { SetProperty } from './setProperty'; -import { StringArrayProperty } from './valueArrayProperty'; -import { StringMapProperty } from './valueMapProperty'; import { StringProperty } from './stringProperty'; -import { Uint16ArrayProperty } from './valueArrayProperty'; -import { Uint16MapProperty } from './valueMapProperty'; -import { Uint16Property } from './uintProperties'; -import { Uint32ArrayProperty } from './valueArrayProperty'; -import { Uint32MapProperty } from './valueMapProperty'; -import { Uint32Property } from './uintProperties'; -import { Uint64ArrayProperty } from './valueArrayProperty'; -import { Uint64MapProperty } from './valueMapProperty'; -import { Uint64Property } from './intProperties'; -import { Uint8ArrayProperty } from './valueArrayProperty'; -import { Uint8MapProperty } from './valueMapProperty'; -import { Uint8Property } from './uintProperties'; -import { ValueArrayProperty } from './valueArrayProperty'; -import { ValueMapProperty } from './valueMapProperty'; +import { + Uint16Property, + Uint32Property, + Uint8Property, +} from './uintProperties'; +import { + BoolArrayProperty, + Float32ArrayProperty, + Float64ArrayProperty, + Int16ArrayProperty, + Int32ArrayProperty, + Int64ArrayProperty, + Int8ArrayProperty, + StringArrayProperty, + Uint16ArrayProperty, + Uint32ArrayProperty, + Uint64ArrayProperty, + Uint8ArrayProperty, + ValueArrayProperty, +} from './valueArrayProperty'; +import { + BoolMapProperty, + Float32MapProperty, + Float64MapProperty, + Int16MapProperty, + Int32MapProperty, + Int64MapProperty, + Int8MapProperty, + StringMapProperty, + Uint16MapProperty, + Uint32MapProperty, + Uint64MapProperty, + Uint8MapProperty, + ValueMapProperty, +} from './valueMapProperty'; import { ValueProperty } from './valueProperty'; -import { _castFunctors } from './primitiveTypeCasts'; export { ArrayProperty, @@ -112,5 +122,5 @@ export { ValueArrayProperty, ValueMapProperty, ValueProperty, - _castFunctors -} + _castFunctors, +}; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/indexedCollectionBaseProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/indexedCollectionBaseProperty.js index 10c0f43a3212..bf5ddc5eebd6 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/indexedCollectionBaseProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/indexedCollectionBaseProperty.js @@ -6,14 +6,14 @@ /** * @fileoverview Abstract base class for indexed collections (sets and maps) */ -const _ = require('lodash'); -const { BaseProperty } = require('./baseProperty'); -const { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty'); -const { deserialize } = require('../containerSerializer'); const { ChangeSet } = require('@fluid-experimental/property-changeset'); const { ConsoleUtils } = require('@fluid-experimental/property-common'); const { MSG } = require('@fluid-experimental/property-common').constants; +const _ = require('lodash'); +const { deserialize } = require('../containerSerializer'); const { validationsEnabled } = require('../enableValidations'); +const { BaseProperty } = require('./baseProperty'); +const { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty'); /** * typedef {property-properties.BaseProperty|string|number|boolean} property-properties.IndexedCollectionBaseProperty~ValueType @@ -27,7 +27,6 @@ const { validationsEnabled } = require('../enableValidations'); * directly. */ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionProperty { - /** * @param {Object} in_params - Input parameters for property creation * @@ -39,16 +38,16 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope this._pendingChanges = { insert: {}, remove: {}, - modify: {} + modify: {}, }; /** Stores the dirty changes in the property (those that have not yet been reported to the application) */ this._dirtyChanges = { insert: {}, remove: {}, - modify: {} + modify: {}, }; - }; + } /** * Removes the dirtiness flag from this property @@ -76,7 +75,7 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope this._dirtyChanges.remove = {}; this._dirtyChanges.modify = {}; } - }; + } /** * Removes the dirtiness flag from this property and recursively from all of its children @@ -122,7 +121,7 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope // after all entries have been cleaned, we mark this property as clean this._cleanDirty(in_flags); - }; + } /** * Inserts a property into the collection @@ -136,14 +135,14 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope * When batching updates, this can be prevented via this flag. */ _insert(in_key, in_value, in_reportToView) { - if (validationsEnabled.enabled) { - this._checkIsNotReadOnly(false); - } + if (validationsEnabled.enabled) { + this._checkIsNotReadOnly(false); + } if (!this.has(in_key)) { // Make sure, the property we are inserting is not already part of some other collection if (validationsEnabled.enabled && !this._containsPrimitiveTypes) { - in_value._validateInsertIn(this) + in_value._validateInsertIn(this); } this._dynamicChildren[in_key] = in_value; @@ -188,7 +187,7 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope } else { throw new Error(MSG.PROPERTY_ALREADY_EXISTS + in_key); } - }; + } /** * Removes an entry with the given key @@ -233,7 +232,7 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope } else { throw new Error(MSG.REMOVED_NON_EXISTING_ENTRY + in_key); } - }; + } /** * Serialize the property @@ -262,7 +261,7 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope var that = this; // Helper function to decide whether to include a typeid or not in the ChangeSet - var addEntryInChangeSet = function (in_changes, in_typeid, in_key, in_value) { + var addEntryInChangeSet = function(in_changes, in_typeid, in_key, in_value) { // Determine where to insert the key. If necessary, an entry for the type is added. if (that._containsPrimitiveTypes) { in_changes[in_key] = that._serializeValue(in_value); @@ -289,7 +288,6 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope var entry = this._dynamicChildren[key]; typeid = this._containsPrimitiveTypes ? this.getFullTypeid(false) : entry.getFullTypeid(false); if (in_dirtyOnly) { - if (changes.insert[key]) { // If the key was inserted in this ChangeSet include it into the inserted list if (this._containsPrimitiveTypes) { @@ -339,7 +337,7 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope } return serialized; - }; + } /** * Function to deserialize special primitive types. @@ -351,7 +349,7 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope */ _deserializeValue(in_serializedObj) { return in_serializedObj; - }; + } /** * Function to serialize special primitive types. @@ -365,7 +363,7 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope ConsoleUtils.assert(this._containsPrimitiveTypes, MSG.ASSERTION_FAILED + 'Function IndexedCollectionBaseProperty._serializeValue() called on non-primitive collection'); return in_obj; - }; + } /** * @inheritdoc @@ -373,7 +371,6 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope // eslint-disable-next-line complexity _deserialize(in_serializedObj, in_reportToView, in_filteringOptions, in_createChangeSet) { - var currentEntries = this._dynamicChildren; var allInsertedKeys = {}; @@ -383,7 +380,7 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope // Perform updates to the children // We make copies on two levels, since those are modified by the calls below - var insertedEntries = _.mapValues(in_serializedObj.insert, function (x) { return _.clone(x); }) || {}; + var insertedEntries = _.mapValues(in_serializedObj.insert, function(x) { return _.clone(x); }) || {}; var removedEntries = {}; var modifiedEntries = {}; @@ -471,7 +468,6 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope } } - // If no typeids are included, we just use a placeholder for the iteration below var classKeys = this._containsPrimitiveTypes ? [undefined] : _.keys(modifiedEntries); @@ -557,7 +553,7 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope } return appliedChangeset; - }; + } /** * @inheritdoc @@ -642,7 +638,6 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope this._dirtyChanges.modify[key] = true; mapWasChangedByModify = true; } - } else { this._dynamicChildren[key]._applyChangeset(modifiedEntries[key], false); } @@ -663,7 +658,7 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope if (in_reportToView) { this._reportDirtinessToView(); } - }; + } /** * @inheritdoc @@ -726,7 +721,7 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope } } } - }; + } /** * @inheritdoc @@ -736,7 +731,6 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope if (in_callingChild && !this._containsPrimitiveTypes) { var key = in_callingChild.getId(); if (this._dynamicChildren[key]) { - if (!this._pendingChanges.insert[key]) { this._pendingChanges.modify[key] = true; } @@ -748,7 +742,7 @@ export class IndexedCollectionBaseProperty extends AbstractStaticCollectionPrope // Forward dirtiness propagation to base class BaseProperty.prototype._setDirty.call(this, in_reportToView, in_callingChild); - }; + } } /** Specifies, whether this is a collection of base types or of registered templates */ IndexedCollectionBaseProperty.prototype._containsPrimitiveTypes = false; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/intProperties.js b/experimental/PropertyDDS/packages/property-properties/src/properties/intProperties.js index fa9e3ef45c51..81ce7aa2c48c 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/intProperties.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/intProperties.js @@ -2,21 +2,21 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -/* eslint-disable new-cap*/ +/* eslint-disable new-cap */ /** * @fileoverview Definition of the Int*Property classes */ const _ = require('lodash'); -const { ValueProperty } = require('./valueProperty'); -const { _castFunctors } = require('./primitiveTypeCasts'); const { ChangeSet } = require('@fluid-experimental/property-changeset'); const { ConsoleUtils, constants: { MSG }, Uint64, - Int64 + Int64, } = require('@fluid-experimental/property-common'); +const { ValueProperty } = require('./valueProperty'); +const { _castFunctors } = require('./primitiveTypeCasts'); const BIT32 = 4294967296; @@ -34,7 +34,7 @@ export class Int8Property extends ValueProperty { super(in_params); // default for this property type is '0' this._data = 0; - }; + } } Int8Property.prototype._typeid = 'Int8'; Int8Property.prototype._castFunctor = _castFunctors.Int8; @@ -55,8 +55,7 @@ export class Int16Property extends ValueProperty { super(in_params); // default for this property type is '0' this._data = 0; - - }; + } } Int16Property.prototype._typeid = 'Int16'; Int16Property.prototype._castFunctor = _castFunctors.Int16; @@ -77,8 +76,7 @@ export class Int32Property extends ValueProperty { super(in_params); // default for this property type is '0' this._data = 0; - - }; + } } Int32Property.prototype._typeid = 'Int32'; Int32Property.prototype._castFunctor = _castFunctors.Int32; @@ -99,11 +97,10 @@ export class Integer64Property extends ValueProperty { */ constructor(in_params, dataConstructor) { super(in_params); - this.DataConstructor = dataConstructor + this.DataConstructor = dataConstructor; // default for this property type is '0, 0' this._data = new this.DataConstructor(); - }; - + } /** * Internal function to update the value of the Integer64Property @@ -131,21 +128,21 @@ export class Integer64Property extends ValueProperty { this._setDirty(in_reportToView); } return changed; - }; + } /** * @return {number} the higher 32 bit integer part */ getValueHigh() { return this._data.getValueHigh(); - }; + } /** * @return {number} the lower 32 bit integer part */ getValueLow() { return this._data.getValueLow(); - }; + } /** * @param {number} in_high set the higher 32 bit integer part @@ -162,7 +159,7 @@ export class Integer64Property extends ValueProperty { this._setDirty(); } return changed; - }; + } /** * @param {number} in_low set the lower 32 bit integer part @@ -179,7 +176,7 @@ export class Integer64Property extends ValueProperty { this._setDirty(); } return changed; - }; + } /** * @inheritdoc @@ -194,7 +191,7 @@ export class Integer64Property extends ValueProperty { var changed = this._setValue(readValue, in_reportToView); return changed ? this.serialize() : undefined; } - }; + } /** * @inheritdoc @@ -208,7 +205,7 @@ export class Integer64Property extends ValueProperty { var newVal = new this.DataConstructor(in_changeSet[0], in_changeSet[1]); this._setValue(newVal, in_reportToView); } - }; + } /** * Serialize the property @@ -237,9 +234,7 @@ export class Integer64Property extends ValueProperty { } else { return [this._data.getValueLow(), this._data.getValueHigh()]; } - }; - - + } /** * The toString() method returns a string representing the specified Integer64 object. @@ -250,7 +245,7 @@ export class Integer64Property extends ValueProperty { */ toString(in_radix) { return this._data.toString(in_radix); - }; + } /** * The Integer64.fromString() method parses a string argument updates object's lower and higher 32 bit integer parts. @@ -269,8 +264,7 @@ export class Integer64Property extends ValueProperty { this.setValueHigh(int.getValueHigh()); this.setValueLow(int.getValueLow()); - }; - + } } /** @@ -287,7 +281,7 @@ export class Int64Property extends Integer64Property { */ constructor(in_params) { super(in_params, Int64); - }; + } } Int64Property.prototype._typeid = 'Int64'; Int64Property.prototype._castFunctor = _castFunctors.Int64; @@ -306,7 +300,7 @@ export class Uint64Property extends Integer64Property { */ constructor(in_params) { super(in_params, Uint64); - }; -}; + } +} Uint64Property.prototype._typeid = 'Uint64'; Uint64Property.prototype._castFunctor = _castFunctors.Uint64; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/lazyLoadedProperties.js b/experimental/PropertyDDS/packages/property-properties/src/properties/lazyLoadedProperties.js index 02d010ffb6cd..6953fad50471 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/lazyLoadedProperties.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/lazyLoadedProperties.js @@ -22,4 +22,3 @@ export const LazyLoadedProperties = { NodeProperty: undefined, IndexedCollectionBaseProperty: undefined, }; - diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/mapProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/mapProperty.js index 0f6cbcdd857f..07dea6a7b39a 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/mapProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/mapProperty.js @@ -6,13 +6,13 @@ /** * @fileoverview Definition of the map property class */ +const { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset'); +const { MSG } = require('@fluid-experimental/property-common').constants; +const { ConsoleUtils } = require('@fluid-experimental/property-common'); const _ = require('lodash'); -const { BaseProperty } = require('./baseProperty'); const { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty'); +const { BaseProperty } = require('./baseProperty'); const { IndexedCollectionBaseProperty } = require('./indexedCollectionBaseProperty'); -const { ConsoleUtils } = require('@fluid-experimental/property-common'); -const { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset'); -const { MSG } = require('@fluid-experimental/property-common').constants; const { LazyLoadedProperties: Property } = require('./lazyLoadedProperties'); const PATH_TOKENS = BaseProperty.PATH_TOKENS; @@ -28,7 +28,6 @@ const PATH_TOKENS = BaseProperty.PATH_TOKENS; * A MapProperty is a collection class that can contain an dictionary that maps from strings to properties. */ export class MapProperty extends IndexedCollectionBaseProperty { - /** * @param {Object} in_params - Input parameters for property creation * @param {string|undefined} in_scope - The scope in which the map typeid is defined @@ -46,7 +45,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { /** Contains the actual entries of the map */ this._dynamicChildren = {}; - }; + } /** * Returns the full property type identifier for the ChangeSet including the enum type id @@ -59,7 +58,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { } else { return TypeIdHelper.createSerializationTypeId(this._typeid, 'map'); } - }; + } /** * Is this property a leaf node with regard to flattening? @@ -70,7 +69,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { */ _isFlattenLeaf() { return true; - }; + } /** * Sets multiple values in a map. @@ -84,7 +83,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { _setValuesInternal(in_values, in_typed) { if (this._containsPrimitiveTypes) { var that = this; - _.each(in_values, function (value, key) { + _.each(in_values, function(value, key) { if (that.has(key)) { that.remove(key); } @@ -93,7 +92,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { }); } else { var that = this; - _.each(in_values, function (value, key) { + _.each(in_values, function(value, key) { var property = that.get(String(key), { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER }); // if key exists in set replace its value else insert a new key/value if (property) { @@ -119,7 +118,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { } }); } - }; + } /** * Sets multiple values in a map. @@ -137,7 +136,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { } this._setValuesInternal(in_values, in_typed); - }; + } /** * Sets multiple values in a map. @@ -156,7 +155,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { } else { this._setValues(in_values, false, false); } - }; + } /** * Returns an object with all the nested values contained in this property @@ -182,7 +181,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { } } return result; - }; + } /** * Returns the path segment for a child @@ -194,7 +193,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { */ _getPathSegmentForChildNode(in_childNode) { return '[' + PathHelper.quotePathSegmentIfNeeded(in_childNode._id) + ']'; - }; + } /** * Resolves a direct child node based on the given path segment @@ -212,7 +211,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { } else { return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType); } - }; + } /** * Inserts a property or value into the map @@ -239,11 +238,10 @@ export class MapProperty extends IndexedCollectionBaseProperty { // Insert the entry into the collection this._insert(in_key, in_property, true); - } else { throw new Error(MSG.NONVALUE_MAP_INSERT_PROP); } - }; + } /** * Removes the entry with the given key from the map @@ -256,7 +254,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { var item = this.get(in_key); this._removeByKey(in_key, true); return item; - }; + } /** * Sets the entry with the given key to the property passed in @@ -287,7 +285,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { // Make one final report this._reportDirtinessToView(); } - }; + } /** * Returns an Object with all the entries of the map. @@ -300,7 +298,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { */ getEntriesReadOnly() { return this._dynamicChildren; - }; + } /** * Returns the collection entry with the given key @@ -347,7 +345,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { return prop; } - }; + } /** * Checks whether an entry with the given name exists @@ -357,7 +355,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { */ has(in_id) { return this._dynamicChildren[in_id] !== undefined; - }; + } /** * Returns all entries of the map as an array. @@ -369,7 +367,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { */ getAsArray() { return _.values(this._dynamicChildren); - }; + } /** * Returns all keys found in the map @@ -380,7 +378,7 @@ export class MapProperty extends IndexedCollectionBaseProperty { */ getIds() { return Object.keys(this._dynamicChildren); - }; + } /** * Get the scope to which this property belongs to. @@ -397,18 +395,17 @@ export class MapProperty extends IndexedCollectionBaseProperty { } else { return this._scope; } - }; + } /** * Deletes all values from the Map */ clear() { var that = this; - this.getIds().forEach(function (id) { + this.getIds().forEach(function(id) { that.remove(id); }); - }; - + } } MapProperty.prototype._typeid = 'BaseProperty'; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/namedNodeProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/namedNodeProperty.js index c546aab0a02d..abb8ec95f79e 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/namedNodeProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/namedNodeProperty.js @@ -15,7 +15,6 @@ const { NodeProperty } = require('./nodeProperty'); * This makes it possible to store it in a set collection. */ export class NamedNodeProperty extends NodeProperty { - /** * @param {object} in_params - List of parameters * @param {string} in_params.id - id of the property (null, if the GUID should be used for the ID) @@ -54,7 +53,6 @@ export class NamedNodeProperty extends NodeProperty { * @return {string} The URN */ getUrn = NamedProperty.prototype.getUrn; - } NamedNodeProperty.prototype._typeid = 'NamedNodeProperty'; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/namedProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/namedProperty.js index 2450610879ba..847e1d291266 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/namedProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/namedProperty.js @@ -14,7 +14,6 @@ const { BaseProperty } = require('./baseProperty'); * set collection. */ export class NamedProperty extends ContainerProperty { - /** * @param {object} in_params - List of parameters * @param {string} in_params.id - id of the property (null, if the GUID should be used for the ID) @@ -28,7 +27,7 @@ export class NamedProperty extends ContainerProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Returns a string identifying the property @@ -43,7 +42,7 @@ export class NamedProperty extends ContainerProperty { } else { return this.getGuid(); } - }; + } /** * Returns the GUID of this named property @@ -55,17 +54,15 @@ export class NamedProperty extends ContainerProperty { getGuid() { var guid = this.get('guid', { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER }); return guid ? guid.getValue() : ''; - }; - + } // THIS IS DISABLED FOR THE MOMENT, UNTIL WE BETTER UNDERSTAND HOW REFERENCES WORK IN FLUID /** * Return the URN for this named property * @return {string} The URN */ - /*NamedProperty.prototype.getUrn = function() { - - };*/ + /* NamedProperty.prototype.getUrn = function() { + }; */ } NamedProperty.prototype._typeid = 'NamedProperty'; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/nodeProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/nodeProperty.js index 2a8080a4b214..833b186e34e8 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/nodeProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/nodeProperty.js @@ -12,7 +12,6 @@ const { ContainerProperty } = require('./containerProperty'); * A property object that allows to add child properties dynamically. */ export class NodeProperty extends ContainerProperty { - /** * @param {Object} in_params - Input parameters for property creation * @@ -23,19 +22,18 @@ export class NodeProperty extends ContainerProperty { * @category Other Collections */ constructor(in_params) { - super( in_params ); + super(in_params); this._dynamicChildren = {}; - }; + } /** * @inheritdoc */ - isDynamic() { return true; }; + isDynamic() { return true; } /** * @inheritdoc */ - _validateInsert(in_id, in_property) { }; - + _validateInsert(in_id, in_property) { } } NodeProperty.prototype._typeid = 'NodeProperty'; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/primitiveTypeCasts.js b/experimental/PropertyDDS/packages/property-properties/src/properties/primitiveTypeCasts.js index 8bdec7f0d8c8..b2ea5e6ec6d4 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/primitiveTypeCasts.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/primitiveTypeCasts.js @@ -17,7 +17,7 @@ var castArrays = { Int16: new Int16Array(1), Int8: new Int8Array(1), Float32: new Float32Array(1), - Float64: new Float64Array(1) + Float64: new Float64Array(1), }; /** @@ -29,12 +29,11 @@ var castArrays = { * @return {number|string|boolean} The casted value * @private */ -var _simpleCastFunctor = function (in_array, in_value) { +var _simpleCastFunctor = function(in_array, in_value) { in_array[0] = in_value; return in_array[0]; }; - /** * Helper functions to cast the input value to the given type * @protected @@ -49,7 +48,7 @@ const _castFunctors = { * @return {number} The casted value * @protected */ - Uint64: function (in_value, in_radix) { + Uint64: function(in_value, in_radix) { if (in_value instanceof Uint64) { return in_value; } @@ -90,7 +89,7 @@ const _castFunctors = { * @return {number} The casted value * @protected */ - Int64: function (in_value, in_radix) { + Int64: function(in_value, in_radix) { if (in_value instanceof Int64) { return in_value; } @@ -143,7 +142,7 @@ const _castFunctors = { * @return {number} The casted value * @protected */ - String: function (in_value) { + String: function(in_value) { return String(in_value); }, /** @@ -152,9 +151,9 @@ const _castFunctors = { * @return {boolean} The casted value * @protected */ - Boolean: function (in_value) { + Boolean: function(in_value) { return !!in_value; - } + }, }; export { _castFunctors }; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/referenceArrayProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/referenceArrayProperty.js index 851714de0f2f..ad2278c9d0f2 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/referenceArrayProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/referenceArrayProperty.js @@ -5,20 +5,19 @@ /** * @fileoverview Definition of the reference array property class */ -const _ = require('lodash'); -const { ValueArrayProperty } = require('./valueArrayProperty'); const { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset'); -const { BaseProperty } = require('./baseProperty'); const { MSG } = require('@fluid-experimental/property-common').constants; const { UniversalDataArray, ConsoleUtils } = require('@fluid-experimental/property-common'); +const _ = require('lodash'); const { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty'); +const { BaseProperty } = require('./baseProperty'); const { ReferenceProperty } = require('./referenceProperty'); +const { ValueArrayProperty } = require('./valueArrayProperty'); /** * An ArrayProperty which stores reference values */ export class ReferenceArrayProperty extends ValueArrayProperty { - /** * @param {Object} in_params - Input parameters for property creation * @@ -30,7 +29,7 @@ export class ReferenceArrayProperty extends ValueArrayProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Returns the typeid for the target of this reference @@ -42,7 +41,7 @@ export class ReferenceArrayProperty extends ValueArrayProperty { */ getReferenceTargetTypeId() { return TypeIdHelper.extractReferenceTargetTypeIdFromReference(this.getTypeid()); - }; + } /** * Resolves the referenced property for the given key @@ -77,7 +76,7 @@ export class ReferenceArrayProperty extends ValueArrayProperty { return this.getParent().resolvePath(value, in_options); } - }; + } /** * Checks whether the reference is valid. This is either the case when it is empty or when the referenced @@ -89,7 +88,7 @@ export class ReferenceArrayProperty extends ValueArrayProperty { isReferenceValid(in_position) { return ValueArrayProperty.prototype.get.call(this, in_position) === '' || this.get(in_position) !== undefined; - }; + } /** * Sets the range in the array to point to the given property objects or to be equal to the given paths @@ -105,7 +104,7 @@ export class ReferenceArrayProperty extends ValueArrayProperty { setRange(in_offset, in_array) { var arr = ReferenceArrayProperty._convertInputToPaths(in_array, 'setRange'); ValueArrayProperty.prototype.setRange.call(this, in_offset, arr); - }; + } /** * Insert a range which points to the given property objects into the array @@ -121,7 +120,7 @@ export class ReferenceArrayProperty extends ValueArrayProperty { insertRange(in_offset, in_array) { var arr = ReferenceArrayProperty._convertInputToPaths(in_array, 'insertRange'); ValueArrayProperty.prototype.insertRange.call(this, in_offset, arr); - }; + } /** * returns the path value of a reference. @@ -130,7 +129,7 @@ export class ReferenceArrayProperty extends ValueArrayProperty { */ getValue(in_id) { return this._dataArrayRef.getValue(in_id); - }; + } /** * Returns an object with all the nested values contained in this property @@ -144,7 +143,7 @@ export class ReferenceArrayProperty extends ValueArrayProperty { result.push(this.getValue(ids[i])); } return result; - }; + } /** * Removes the last element of the array @@ -159,7 +158,7 @@ export class ReferenceArrayProperty extends ValueArrayProperty { } else { return undefined; } - }; + } /** * Removes an element of the array and shift remaining elements to the left @@ -173,7 +172,7 @@ export class ReferenceArrayProperty extends ValueArrayProperty { var value = this.getValue(in_position); this.removeRange(in_position, 1); return value; - }; + } /** * Removes a given number of elements from the array and shifts remaining values to the left. @@ -200,13 +199,12 @@ export class ReferenceArrayProperty extends ValueArrayProperty { this._removeRangeWithoutDirtying(in_offset, in_deleteCount); this._setDirty(); return result; - }; + } /** * @inheritdoc */ _resolvePathSegment(in_segment, in_segmentType) { - // Array tokens are automatically resolved if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN) { return this.get(in_segment, { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER }); @@ -214,7 +212,7 @@ export class ReferenceArrayProperty extends ValueArrayProperty { // Everything else is handled by the implementation in the base property return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType); } - }; + } /** * Creates and initializes the data array @@ -225,7 +223,7 @@ export class ReferenceArrayProperty extends ValueArrayProperty { for (var i = 0; i < in_length; i++) { this._dataArraySetValue(i, ''); } - }; + } /** * Validates the array and returns a sanitized version of it containing only strings. @@ -239,7 +237,7 @@ export class ReferenceArrayProperty extends ValueArrayProperty { * @throws if in_array is not an array * @throws if one of the items in in_array is defined, but is not a property or a string. */ - static _convertInputToPaths = function (in_array, in_callerName) { + static _convertInputToPaths = function(in_array, in_callerName) { if (!_.isArray(in_array)) { throw new Error(MSG.IN_ARRAY_NOT_ARRAY + 'ReferenceArrayProperty.' + in_callerName); } @@ -250,6 +248,5 @@ export class ReferenceArrayProperty extends ValueArrayProperty { } return arr; }; - } ReferenceArrayProperty.prototype._typeid = 'Reference'; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/referenceMapProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/referenceMapProperty.js index 5cbfa244d32c..b7c5dd5dcd04 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/referenceMapProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/referenceMapProperty.js @@ -5,20 +5,18 @@ /** * @fileoverview Definition of the reference map property class */ -const _ = require('lodash'); -const { StringMapProperty } = require('./valueMapProperty'); const { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset'); -const { BaseProperty } = require('./baseProperty'); const { MSG } = require('@fluid-experimental/property-common').constants; +const _ = require('lodash'); +const { BaseProperty } = require('./baseProperty'); const { ContainerProperty } = require('./containerProperty'); const { ReferenceProperty } = require('./referenceProperty'); - +const { StringMapProperty } = require('./valueMapProperty'); /** * A StringMapProperty which stores reference values */ export class ReferenceMapProperty extends StringMapProperty { - /** * @param {Object} in_params - Input parameters for property creation * @@ -30,7 +28,7 @@ export class ReferenceMapProperty extends StringMapProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Returns the typeid for the target of this reference @@ -42,7 +40,7 @@ export class ReferenceMapProperty extends StringMapProperty { */ getReferenceTargetTypeId() { return TypeIdHelper.extractReferenceTargetTypeIdFromReference(this.getTypeid()); - }; + } /** * Resolves the referenced property for the given key @@ -69,7 +67,6 @@ export class ReferenceMapProperty extends StringMapProperty { // Forward handling of arrays to the BaseProperty function return AbstractStaticCollectionProperty.prototype.get.call(this, in_ids, in_options); } else { - var value = this._dynamicChildren[in_ids]; if (value === undefined || value === '') { @@ -77,7 +74,7 @@ export class ReferenceMapProperty extends StringMapProperty { } return this.getParent().resolvePath(value, in_options); } - }; + } /** * Removes the entry with the given key from the map @@ -90,7 +87,7 @@ export class ReferenceMapProperty extends StringMapProperty { var item = this.getValue(in_key); this._removeByKey(in_key, true); return item; - }; + } /** * Returns an object with all the nested path values @@ -107,7 +104,7 @@ export class ReferenceMapProperty extends StringMapProperty { result[ids[i]] = this.getValue(ids[i]); } return result; - }; + } /** * Sets or inserts the reference to point to the given property object or to be equal to the given path string. @@ -126,7 +123,7 @@ export class ReferenceMapProperty extends StringMapProperty { } var value = ReferenceProperty._convertInputToPath(in_value); StringMapProperty.prototype.set.call(this, in_key, value); - }; + } /** * Sets or inserts the reference to point to the given property object or to be equal to the given path string. @@ -156,7 +153,7 @@ export class ReferenceMapProperty extends StringMapProperty { insert(in_key, in_value) { var value = ReferenceProperty._convertInputToPath(in_value); this._insert(in_key, value, true); - }; + } /** * Checks whether the reference is valid. This is either the case when it is empty or when the referenced @@ -169,7 +166,7 @@ export class ReferenceMapProperty extends StringMapProperty { return this.has(in_key) && (this.getValue(in_key) === '' || this.get(in_key) !== undefined); - }; + } /** * Returns the string value stored in the map @@ -178,13 +175,12 @@ export class ReferenceMapProperty extends StringMapProperty { */ getValue(in_key) { return this._getValue(in_key); - }; + } /** * @inheritdoc */ _resolvePathSegment(in_segment, in_segmentType) { - // Array tokens are automatically resolved if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN) { return this.get(in_segment, { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER }); @@ -192,8 +188,7 @@ export class ReferenceMapProperty extends StringMapProperty { // Everything else is handled by the implementation in the base property return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType); } - }; - + } } ReferenceMapProperty.prototype._typeid = 'Reference'; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/referenceProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/referenceProperty.js index 01329b9e736c..b8a909f4259d 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/referenceProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/referenceProperty.js @@ -6,14 +6,13 @@ * @fileoverview Definition of the ReferenceProperty class */ -const _ = require('lodash'); -const { ValueProperty } = require('./valueProperty'); const { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset'); -const { BaseProperty } = require('./baseProperty'); +const { MSG } = require('@fluid-experimental/property-common').constants; +const _ = require('lodash'); const { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty'); +const { BaseProperty } = require('./baseProperty'); const { _castFunctors } = require('./primitiveTypeCasts'); -const { MSG } = require('@fluid-experimental/property-common').constants; - +const { ValueProperty } = require('./valueProperty'); /** * This class serves as a view to read, write and listen to changes in an @@ -35,7 +34,7 @@ export class ReferenceProperty extends ValueProperty { super(in_params); // default for this property type is an empty string this._data = ''; - }; + } /** * Evaluates Reference properties as primitives. @@ -43,7 +42,7 @@ export class ReferenceProperty extends ValueProperty { */ isPrimitiveType() { return true; - }; + } /** * Returns the typeid for the target of this reference @@ -55,7 +54,7 @@ export class ReferenceProperty extends ValueProperty { */ getReferenceTargetTypeId() { return TypeIdHelper.extractReferenceTargetTypeIdFromReference(this.getTypeid()); - }; + } /** * Resolves the referenced property @@ -102,7 +101,7 @@ export class ReferenceProperty extends ValueProperty { } else { return resolvedProperty; } - }; + } /** * Expand a path returning the value or property at the end. @@ -121,7 +120,7 @@ export class ReferenceProperty extends ValueProperty { return undefined; } return AbstractStaticCollectionProperty.prototype.resolvePath.call(this, in_path, in_options); - }; + } /** * Checks whether the reference is valid. This is either the case when it is empty or when the referenced @@ -131,7 +130,7 @@ export class ReferenceProperty extends ValueProperty { */ isReferenceValid() { return this.value === '' || this.ref !== undefined; - }; + } /** * Sets the reference to point to the given property object or to be equal to the given path string. @@ -147,7 +146,7 @@ export class ReferenceProperty extends ValueProperty { var value = ReferenceProperty._convertInputToPath(in_value); // Forward the call to setValue ValueProperty.prototype.setValue.call(this, value); - }; + } /** * Sets the reference to point to the given property object or to be equal to the given path string. @@ -166,7 +165,6 @@ export class ReferenceProperty extends ValueProperty { * @inheritdoc */ _resolvePathSegment(in_segment, in_segmentType) { - // path segments and array tokens are no longer automatically forwarded to the referenced node if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN || in_segmentType === PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN) { @@ -174,7 +172,7 @@ export class ReferenceProperty extends ValueProperty { } else { return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType); } - }; + } // Define a property to simplify accessing the referenced path get ref() { @@ -210,7 +208,6 @@ export class ReferenceProperty extends ValueProperty { } return path; } - } ReferenceProperty.prototype._castFunctor = _castFunctors.String; ReferenceProperty.prototype._typeid = "Reference"; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/setProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/setProperty.js index 1176efc7aa1a..4a1039680a29 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/setProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/setProperty.js @@ -6,12 +6,12 @@ /** * @fileoverview Definition of the set property class */ +const { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset'); +const { MSG } = require('@fluid-experimental/property-common').constants; const _ = require('lodash'); -const { BaseProperty } = require('./baseProperty'); const { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty'); +const { BaseProperty } = require('./baseProperty'); const { IndexedCollectionBaseProperty } = require('./indexedCollectionBaseProperty'); -const { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset'); -const { MSG } = require('@fluid-experimental/property-common').constants; const { LazyLoadedProperties: Property } = require('./lazyLoadedProperties'); var PATH_TOKENS = BaseProperty.PATH_TOKENS; @@ -20,7 +20,6 @@ var PATH_TOKENS = BaseProperty.PATH_TOKENS; * must derive from NamedProperty and their URN is used to identify them within the set. */ export class SetProperty extends IndexedCollectionBaseProperty { - /** * @param {Object} in_params - Input parameters for property creation * @param {string|undefined} in_scope - The scope in which the map typeid is defined @@ -38,7 +37,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { /** Contains the actual entries of the set, indexed by their GUID */ this._dynamicChildren = {}; - }; + } // A set property falls back to NamedProperty, if none is specified @@ -51,7 +50,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { */ _isFlattenLeaf() { return true; - }; + } /** * Returns an object with all the nested values contained in this property @@ -75,7 +74,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { } } return result; - }; + } /** * Returns the full property type identifier for the ChangeSet including the enum type id @@ -88,7 +87,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { } else { return TypeIdHelper.createSerializationTypeId(this._typeid, 'set'); } - }; + } /** * Returns the path segment for a child @@ -100,7 +99,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { */ _getPathSegmentForChildNode(in_childNode) { return '[' + in_childNode.getGuid() + ']'; - }; + } /** * Resolves a direct child node based on the given path segment @@ -118,7 +117,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { } else { return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType); } - }; + } /** * Inserts a property into the set @@ -135,7 +134,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { } else { throw new Error(MSG.CANT_INSERT_NON_NAMED_PROPERTIES); } - }; + } /** * Adds a property to the set @@ -157,7 +156,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { } else { throw new Error(MSG.CANT_INSERT_NON_NAMED_PROPERTIES); } - }; + } /** * Removes the given property from the set @@ -175,7 +174,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { this._removeByKey(in_entry.getGuid(), true); return in_entry; } - }; + } /** * Returns an Object with all the entries of the set. @@ -188,7 +187,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { */ getEntriesReadOnly() { return this._dynamicChildren; - }; + } /** * Returns the name of all the sub-properties of this property. @@ -197,7 +196,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { */ getIds() { return Object.keys(this._dynamicChildren); - }; + } /** * Returns the collection entry with the given ID @@ -235,7 +234,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { return prop; } - }; + } /** * Checks whether a property with the given name exists @@ -245,7 +244,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { */ has(in_id) { return this._dynamicChildren[in_id] !== undefined; - }; + } /** * Adds a list of properties to the set. @@ -259,7 +258,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { this._checkIsNotReadOnly(true); var that = this; - _.each(in_properties, function (property) { + _.each(in_properties, function(property) { if (property instanceof BaseProperty) { that.set(property); } else { @@ -273,7 +272,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { } } }); - }; + } /** * Adds a list of properties to the set. @@ -291,7 +290,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { } this._setValuesInternal(in_properties, in_typed); - }; + } /** * Adds a list of properties to the set. @@ -309,7 +308,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { } else { SetProperty.prototype._setValues.call(this, in_properties, false, false); } - }; + } /** * Returns all entries of the set as an array. @@ -321,7 +320,7 @@ export class SetProperty extends IndexedCollectionBaseProperty { */ getAsArray() { return _.values(this._dynamicChildren); - }; + } /** * Get the scope to which this property belongs to. @@ -338,18 +337,17 @@ export class SetProperty extends IndexedCollectionBaseProperty { } else { return this._scope; } - }; + } /** * Delete all values from Set */ clear() { var that = this; - this.getIds().forEach(function (id) { + this.getIds().forEach(function(id) { that.remove(id); }); - }; - + } } SetProperty.prototype._typeid = 'NamedProperty'; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/stringProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/stringProperty.js index 36fb2a17866b..97f61782b3de 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/stringProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/stringProperty.js @@ -6,13 +6,13 @@ * @fileoverview Definition of the StringProperty class */ -const _ = require('lodash'); -const { ValueArrayProperty } = require('./valueArrayProperty'); -const { ArrayProperty } = require('./arrayProperty'); -const { MSG } = require('@fluid-experimental/property-common').constants; const { ChangeSet } = require('@fluid-experimental/property-changeset'); +const { MSG } = require('@fluid-experimental/property-common').constants; const { ConsoleUtils } = require('@fluid-experimental/property-common'); +const _ = require('lodash'); +const { ArrayProperty } = require('./arrayProperty'); const { BaseProperty } = require('./baseProperty'); +const { ValueArrayProperty } = require('./valueArrayProperty'); var MODIFIED_STATE_FLAGS = BaseProperty.MODIFIED_STATE_FLAGS; @@ -25,12 +25,12 @@ var MODIFIED_STATE_FLAGS = BaseProperty.MODIFIED_STATE_FLAGS; var PENDING_AND_DIRTY_SET_TO_PROPERTY_VALUE = { pending: 'setAsLiteral', dirty: 'setAsLiteral', - flags: MODIFIED_STATE_FLAGS.PENDING_CHANGE | MODIFIED_STATE_FLAGS.DIRTY + flags: MODIFIED_STATE_FLAGS.PENDING_CHANGE | MODIFIED_STATE_FLAGS.DIRTY, }; var NO_DIRTY_AND_PENDING_SET_TO_PROPERTY_VALUE = { pending: 'setAsLiteral', dirty: undefined, - flags: MODIFIED_STATE_FLAGS.PENDING_CHANGE + flags: MODIFIED_STATE_FLAGS.PENDING_CHANGE, }; var DIRTY_AND_NO_PENDING_SET_TO_PROPERTY_VALUE = { @@ -43,14 +43,14 @@ var DIRTY_AND_NO_PENDING_SET_TO_PROPERTY_VALUE = { }, get flags() { return this._flags; - } + }, }; var STRING_PROPERTY_SET_PROPERTY_VALUE_STATE_FLAGS = [ undefined, NO_DIRTY_AND_PENDING_SET_TO_PROPERTY_VALUE, DIRTY_AND_NO_PENDING_SET_TO_PROPERTY_VALUE, - PENDING_AND_DIRTY_SET_TO_PROPERTY_VALUE + PENDING_AND_DIRTY_SET_TO_PROPERTY_VALUE, ]; /** @@ -67,7 +67,7 @@ export class StringProperty extends ValueArrayProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Get the string value @@ -75,7 +75,7 @@ export class StringProperty extends ValueArrayProperty { */ getValue() { return this._dataArrayRef; - }; + } /** * Private helper function to update the internal dirty and pending changes @@ -113,7 +113,7 @@ export class StringProperty extends ValueArrayProperty { } this._setChanges(pendingChanges, dirtyChanges); - }; + } _getPendingChanges() { if (this._dirty === PENDING_AND_DIRTY_SET_TO_PROPERTY_VALUE || @@ -122,7 +122,7 @@ export class StringProperty extends ValueArrayProperty { } return (this._dirty && this._dirty.pending) || {}; - }; + } _getDirtyChanges() { if (this._dirty === PENDING_AND_DIRTY_SET_TO_PROPERTY_VALUE || @@ -133,7 +133,7 @@ export class StringProperty extends ValueArrayProperty { } return (this._dirty && this._dirty.dirty) || {}; - }; + } /** * inserts a string starting at a position and shifts the rest of @@ -146,7 +146,7 @@ export class StringProperty extends ValueArrayProperty { insert(in_position, in_value) { ConsoleUtils.assert(_.isString(in_value), MSG.IN_VALUE_MUST_BE_STRING + in_value); this._insertRange(in_position, in_value); - }; + } /** * Adds letters to the end of the string @@ -158,8 +158,7 @@ export class StringProperty extends ValueArrayProperty { ConsoleUtils.assert(_.isString(in_value), MSG.IN_VALUE_MUST_BE_STRING + in_value); this._insertRange(this._dataArrayRef.length, in_value); return this.getLength(); - }; - + } /** * inserts values @@ -170,7 +169,7 @@ export class StringProperty extends ValueArrayProperty { this._checkIsNotReadOnly(true); this._insertRangeWithoutDirtying(in_position, in_value); this._setDirty(); - }; + } /** * Returns the full property type identifier for the ChangeSet including the enum type id @@ -180,14 +179,14 @@ export class StringProperty extends ValueArrayProperty { */ getFullTypeid(in_hideCollection) { return this._typeid; - }; + } /** * returns the String to an empty string. */ clear() { this.setValue(''); - }; + } /** * removes a given number of elements from the array property and shifts @@ -215,8 +214,7 @@ export class StringProperty extends ValueArrayProperty { this._removeRangeWithoutDirtying(in_offset, in_deleteCount); this._setDirty(); return result; - }; - + } /** * @inheritdoc @@ -248,7 +246,7 @@ export class StringProperty extends ValueArrayProperty { if (oldStringLength > 0) { this.removeRange(0, oldStringLength, in_reportToView); return { - remove: [[0, oldStringLength]] + remove: [[0, oldStringLength]], }; } else { // the string was already empty, nothing has changed @@ -268,7 +266,7 @@ export class StringProperty extends ValueArrayProperty { if (newStringData.length > oldStringLength) { if (newStringData.substring(0, oldStringLength) === this._dataArrayRef) { var appendChanges = { - insert: [[oldStringLength, newStringData.substring(oldStringLength)]] + insert: [[oldStringLength, newStringData.substring(oldStringLength)]], }; this.insertRange(oldStringLength, newStringData.substring(oldStringLength), in_reportToView); return appendChanges; @@ -277,7 +275,7 @@ export class StringProperty extends ValueArrayProperty { // most simplistic diff method: Remove all existing data and insert the new data var simpleChanges = { - insert: [[0, newStringData]] + insert: [[0, newStringData]], }; if (oldStringLength > 0) { simpleChanges.remove = [[0, oldStringLength]]; @@ -285,7 +283,7 @@ export class StringProperty extends ValueArrayProperty { } this.insertRange(0, newStringData, in_reportToView); return simpleChanges; - }; + } /** * Serialize the property @@ -312,7 +310,7 @@ export class StringProperty extends ValueArrayProperty { // returns just the current data return this._dataArrayRef; } - }; + } /** * @param {string} in_value the new value @@ -321,7 +319,7 @@ export class StringProperty extends ValueArrayProperty { setValue(in_value) { this._checkIsNotReadOnly(true); this._setValue(in_value, true); - }; + } /** * @param {string} in_values the new values @@ -331,7 +329,7 @@ export class StringProperty extends ValueArrayProperty { */ _setValues(in_values, in_initial) { throw new Error(MSG.NO_VALUE_PROPERTY_SETVALUES); - }; + } /** * @param {string} in_values the new values @@ -339,15 +337,14 @@ export class StringProperty extends ValueArrayProperty { */ setValues(in_values) { StringProperty.prototype._setValues.call(this, in_values, false); - }; + } /** * @throws always - cannot call .getValues on a string. Use .getValue() instead */ getValues() { throw new Error(MSG.NO_VALUE_PROPERTY_GETVALUES); - }; - + } /** * Internal function to update the value of a property @@ -363,7 +360,6 @@ export class StringProperty extends ValueArrayProperty { var castedValue = String(in_value); var changed = castedValue !== oldValue; if (changed) { - var stringLength = this._dataArrayRef.length; if (stringLength > 0) { this._dataArrayRemoveRange(0, stringLength); @@ -382,7 +378,7 @@ export class StringProperty extends ValueArrayProperty { } } return changed; - }; + } /** * Sets the pending and dirty changesets @@ -409,7 +405,7 @@ export class StringProperty extends ValueArrayProperty { } else { ArrayProperty.prototype._setChanges.call(this, in_pending, in_dirty); } - }; + } /** * Sets the dirty flags for this property @@ -424,7 +420,7 @@ export class StringProperty extends ValueArrayProperty { } ArrayProperty.prototype._setDirtyFlags.call(this, in_flags); - }; + } /** * Gets the dirty flags for this property @@ -438,7 +434,7 @@ export class StringProperty extends ValueArrayProperty { } return ArrayProperty.prototype._getDirtyFlags.call(this); - }; + } /** * @inheritdoc @@ -459,7 +455,7 @@ export class StringProperty extends ValueArrayProperty { // Let's consider it's an ArrayProperty-like changeset ArrayProperty.prototype._applyChangeset.call(this, in_changeSet, in_reportToView); } - }; + } /** * Calls back the given function with a human-readable string @@ -471,7 +467,7 @@ export class StringProperty extends ValueArrayProperty { */ _prettyPrint(indent, externalId, printFct) { printFct(indent + externalId + this.getId() + ' (' + this.getTypeid() + '): "' + this.value + '"'); - }; + } /** * Return a JSON representation of the property. @@ -484,9 +480,9 @@ export class StringProperty extends ValueArrayProperty { context: this._context, typeid: this.getTypeid(), isConstant: this._isConstant, - value: this.value + value: this.value, }; - }; + } /** * Sets the value of a character at a single index. @@ -503,7 +499,7 @@ export class StringProperty extends ValueArrayProperty { } this.setRange(in_index, in_character); - }; + } /** * sets values in a string starting at an index. @@ -515,7 +511,7 @@ export class StringProperty extends ValueArrayProperty { */ setRange(in_index, in_string) { ArrayProperty.prototype.setRange.call(this, in_index, in_string); - }; + } /** * get a letter at a given index @@ -524,7 +520,7 @@ export class StringProperty extends ValueArrayProperty { */ get(in_index) { return ArrayProperty.prototype.get.call(this, in_index); - }; + } /** * inserts a string starting at a position and shifts the rest of the String to the right. @@ -540,7 +536,7 @@ export class StringProperty extends ValueArrayProperty { in_value = in_value.join(''); } this._insertRange(in_position, in_value); - }; + } /** * Creates and initializes the data array @@ -548,7 +544,7 @@ export class StringProperty extends ValueArrayProperty { */ _dataArrayCreate(in_length) { this._dataArrayRef = ''; - }; + } /** * Returns the length of the data array @@ -556,7 +552,7 @@ export class StringProperty extends ValueArrayProperty { */ _dataArrayGetLength() { return this._dataArrayRef.length; - }; + } /** * Returns the data array's internal buffer @@ -564,7 +560,7 @@ export class StringProperty extends ValueArrayProperty { */ _dataArrayGetBuffer() { return this._dataArrayRef; - }; + } /** * Returns an entry from the data array @@ -579,7 +575,7 @@ export class StringProperty extends ValueArrayProperty { } return this._dataArrayRef[in_i]; - }; + } /** * Set the array to the given new array @@ -587,7 +583,7 @@ export class StringProperty extends ValueArrayProperty { */ _dataArrayDeserialize(in_newString) { this._dataArrayRef = in_newString; - }; + } /** * Inserts a range into the data array @@ -596,7 +592,7 @@ export class StringProperty extends ValueArrayProperty { */ _dataArrayInsertRange(in_position, in_range) { this._dataArrayRef = this._dataArrayRef.substr(0, in_position) + in_range + this._dataArrayRef.substr(in_position); - }; + } /** * Removes a range from the data array @@ -610,7 +606,7 @@ export class StringProperty extends ValueArrayProperty { } else { throw Error('DataArray removeRange in_offset + in_deleteCount is out of bounds.'); } - }; + } /** * Overwrites a range in the data array @@ -620,8 +616,7 @@ export class StringProperty extends ValueArrayProperty { _dataArraySetRange(in_position, in_values) { this._dataArrayRef = this._dataArrayRef.substr(0, in_position) + in_values + this._dataArrayRef.substr(in_position + in_values.length); - }; - + } get value() { return this.getValue(); diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/uintProperties.js b/experimental/PropertyDDS/packages/property-properties/src/properties/uintProperties.js index c53fcef2eb28..ecefc0e2da8d 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/uintProperties.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/uintProperties.js @@ -25,7 +25,7 @@ export class Uint8Property extends ValueProperty { super(in_params); // default for this property type is '0' this._data = 0; - }; + } } Uint8Property.prototype._typeid = 'Uint8'; Uint8Property.prototype._castFunctor = _castFunctors.Uint8; @@ -46,7 +46,7 @@ export class Uint16Property extends ValueProperty { super(in_params); // default for this property type is '0' this._data = 0; - }; + } } Uint16Property.prototype._typeid = 'Uint16'; Uint16Property.prototype._castFunctor = _castFunctors.Uint16; @@ -67,7 +67,7 @@ export class Uint32Property extends ValueProperty { super(in_params); // default for this property type is '0' this._data = 0; - }; + } } Uint32Property.prototype._typeid = 'Uint32'; Uint32Property.prototype._castFunctor = _castFunctors.Uint32; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/valueArrayProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/valueArrayProperty.js index 7967a0dd4852..21bc60cd53d8 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/valueArrayProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/valueArrayProperty.js @@ -2,29 +2,28 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -/* eslint-disable new-cap*/ +/* eslint-disable new-cap */ /** * @fileoverview Definition of the valuearray property class */ const _ = require('lodash'); const { MSG } = require('@fluid-experimental/property-common').constants; -const { _castFunctors } = require('./primitiveTypeCasts'); const { BaseDataArray, UniversalDataArray, BoolDataArray, Uint64, - Int64 + Int64, } = require('@fluid-experimental/property-common'); -const { ArrayProperty } = require('./arrayProperty'); const { Int64Property, Uint64Property } = require('../properties/intProperties'); +const { _castFunctors } = require('./primitiveTypeCasts'); +const { ArrayProperty } = require('./arrayProperty'); /** * An array property which stores primitive values */ export class ValueArrayProperty extends ArrayProperty { - /** * @param {Object} in_params - Input parameters for property creation * @constructor @@ -34,7 +33,7 @@ export class ValueArrayProperty extends ArrayProperty { */ constructor(in_params) { super(in_params, true); - }; + } /** * returns the value at in_position for a primitive array @@ -43,7 +42,7 @@ export class ValueArrayProperty extends ArrayProperty { */ _getValue(in_position) { return this._dataArrayRef.getValue(in_position); - }; + } /** * returns the array of primitive values. @@ -57,7 +56,7 @@ export class ValueArrayProperty extends ArrayProperty { result.push(this.get(ids[i])); } return result; - }; + } /** * Resolves a direct child node based on the given path segment @@ -70,7 +69,7 @@ export class ValueArrayProperty extends ArrayProperty { */ _resolvePathSegment(in_segment, in_segmentType) { return this.get(in_segment); - }; + } /** * Function to serialize special primitive types. @@ -82,7 +81,7 @@ export class ValueArrayProperty extends ArrayProperty { */ _serializeValue(in_obj) { return in_obj; - }; + } /** * Function to serialize arrays of special primitive types. @@ -94,7 +93,7 @@ export class ValueArrayProperty extends ArrayProperty { */ _serializeArray(in_array) { return in_array; - }; + } /** * Function to deserialize arrays of special primitive types. @@ -106,7 +105,7 @@ export class ValueArrayProperty extends ArrayProperty { */ _deserializeArray(in_serializedObj) { return in_serializedObj; - }; + } } ValueArrayProperty.prototype._isPrimitive = true; @@ -125,7 +124,7 @@ export class Float32ArrayProperty extends ValueArrayProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Creates and initializes the data array @@ -133,7 +132,7 @@ export class Float32ArrayProperty extends ValueArrayProperty { */ _dataArrayCreate(in_length) { this._dataArrayRef = new BaseDataArray(Float32Array, in_length); - }; + } } Float32ArrayProperty.prototype._typeid = 'Float32'; @@ -152,7 +151,7 @@ export class Float64ArrayProperty extends ValueArrayProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Creates and initializes the data array @@ -160,7 +159,7 @@ export class Float64ArrayProperty extends ValueArrayProperty { */ _dataArrayCreate(in_length) { this._dataArrayRef = new BaseDataArray(Float64Array, in_length); - }; + } } Float64ArrayProperty.prototype._typeid = 'Float64'; @@ -179,7 +178,7 @@ export class Uint8ArrayProperty extends ValueArrayProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Creates and initializes the data array @@ -187,7 +186,7 @@ export class Uint8ArrayProperty extends ValueArrayProperty { */ _dataArrayCreate(in_length) { this._dataArrayRef = new BaseDataArray(Uint8Array, in_length); - }; + } } Uint8ArrayProperty.prototype._typeid = 'Uint8'; @@ -207,7 +206,7 @@ export class Int8ArrayProperty extends ValueArrayProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Creates and initializes the data array @@ -215,7 +214,7 @@ export class Int8ArrayProperty extends ValueArrayProperty { */ _dataArrayCreate(in_length) { this._dataArrayRef = new BaseDataArray(Int8Array, in_length); - }; + } } Int8ArrayProperty.prototype._typeid = 'Int8'; @@ -234,7 +233,7 @@ export class Uint16ArrayProperty extends ValueArrayProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Creates and initializes the data array @@ -242,7 +241,7 @@ export class Uint16ArrayProperty extends ValueArrayProperty { */ _dataArrayCreate(in_length) { this._dataArrayRef = new BaseDataArray(Uint16Array, in_length); - }; + } } Uint16ArrayProperty.prototype._typeid = 'Uint16'; @@ -261,7 +260,7 @@ export class Int16ArrayProperty extends ValueArrayProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Creates and initializes the data array @@ -269,7 +268,7 @@ export class Int16ArrayProperty extends ValueArrayProperty { */ _dataArrayCreate(in_length) { this._dataArrayRef = new BaseDataArray(Int16Array, in_length); - }; + } } Int16ArrayProperty.prototype._typeid = 'Int16'; @@ -287,8 +286,7 @@ export class Uint32ArrayProperty extends ValueArrayProperty { */ constructor(in_params) { super(in_params); - }; - + } /** * Creates and initializes the data array @@ -296,7 +294,7 @@ export class Uint32ArrayProperty extends ValueArrayProperty { */ _dataArrayCreate(in_length) { this._dataArrayRef = new BaseDataArray(Uint32Array, in_length); - }; + } } Uint32ArrayProperty.prototype._typeid = 'Uint32'; @@ -315,7 +313,7 @@ export class Int32ArrayProperty extends ValueArrayProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Creates and initializes the data array @@ -323,7 +321,7 @@ export class Int32ArrayProperty extends ValueArrayProperty { */ _dataArrayCreate(in_length) { this._dataArrayRef = new BaseDataArray(Int32Array, in_length); - }; + } } Int32ArrayProperty.prototype._typeid = 'Int32'; @@ -341,7 +339,7 @@ export class Integer64ArrayProperty extends ValueArrayProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Function to serialize special primitive types. @@ -356,8 +354,7 @@ export class Integer64ArrayProperty extends ValueArrayProperty { return [in_obj.getValueLow(), in_obj.getValueHigh()]; } return in_obj; - }; - + } /** * Function to serialize arrays of special primitive types. @@ -373,7 +370,7 @@ export class Integer64ArrayProperty extends ValueArrayProperty { result.push(this._serializeValue(in_array[i])); } return result; - }; + } /** * Function to deserialize arrays of special primitive types. @@ -389,13 +386,12 @@ export class Integer64ArrayProperty extends ValueArrayProperty { result.push(this._deserializeValue(in_serializedObj[i])); } return result; - }; + } /** * @inheritdoc */ _prettyPrint(indent, externalId, printFct) { - printFct(indent + externalId + this.getId() + ' (Array of ' + this.getTypeid() + '): ['); var childIndent = indent + ' '; var int64Prop; @@ -412,7 +408,7 @@ export class Integer64ArrayProperty extends ValueArrayProperty { printFct(childIndent + i + ': ' + int64Prop); } printFct(indent + ']'); - }; + } } /** * An ArrayProperty which stores Int64 values @@ -429,7 +425,7 @@ export class Int64ArrayProperty extends Integer64ArrayProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Sets the array properties elements to the content of the given array @@ -447,7 +443,7 @@ export class Int64ArrayProperty extends Integer64ArrayProperty { return _castFunctors.Int64(element); }); ArrayProperty.prototype.setRange.call(this, in_offset, out_array); - }; + } /** * Inserts the content of a given array into the array property @@ -464,7 +460,7 @@ export class Int64ArrayProperty extends Integer64ArrayProperty { return _castFunctors.Int64(element); }); ArrayProperty.prototype.insertRange.call(this, in_offset, out_array); - }; + } /** * Specialized function to deserialize Int64 primitive types. @@ -476,7 +472,7 @@ export class Int64ArrayProperty extends Integer64ArrayProperty { */ _deserializeValue(in_serializedObj) { return new Int64(in_serializedObj[0], in_serializedObj[1]); - }; + } /** * Creates and initializes the data array @@ -487,8 +483,7 @@ export class Int64ArrayProperty extends Integer64ArrayProperty { for (var i = 0; i < in_length; i++) { this._dataArraySetValue(i, new Int64()); } - }; - + } } Int64ArrayProperty.prototype._typeid = 'Int64'; @@ -507,7 +502,7 @@ export class Uint64ArrayProperty extends Integer64ArrayProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Specialized function to deserialize Uint64 primitive types. @@ -519,7 +514,7 @@ export class Uint64ArrayProperty extends Integer64ArrayProperty { */ _deserializeValue(in_serializedObj) { return new Uint64(in_serializedObj[0], in_serializedObj[1]); - }; + } /** * Sets the array properties elements to the content of the given array @@ -537,7 +532,7 @@ export class Uint64ArrayProperty extends Integer64ArrayProperty { return _castFunctors.Uint64(element); }); ArrayProperty.prototype.setRange.call(this, in_offset, out_array); - }; + } /** * Inserts the content of a given array into the array property @@ -554,7 +549,7 @@ export class Uint64ArrayProperty extends Integer64ArrayProperty { return _castFunctors.Uint64(element); }); ArrayProperty.prototype.insertRange.call(this, in_offset, out_array); - }; + } /** * Creates and initializes the data array @@ -565,7 +560,7 @@ export class Uint64ArrayProperty extends Integer64ArrayProperty { for (var i = 0; i < in_length; i++) { this._dataArraySetValue(i, new Uint64()); } - }; + } } Uint64ArrayProperty.prototype._typeid = 'Uint64'; @@ -584,7 +579,7 @@ export class StringArrayProperty extends ValueArrayProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Creates and initializes the data array @@ -595,8 +590,7 @@ export class StringArrayProperty extends ValueArrayProperty { for (var i = 0; i < in_length; i++) { this._dataArraySetValue(i, ''); } - }; - + } } StringArrayProperty.prototype._typeid = 'String'; @@ -615,7 +609,7 @@ export class BoolArrayProperty extends ValueArrayProperty { */ constructor(in_params) { super(in_params, Array, true); - }; + } /** * Creates and initializes the data array @@ -626,6 +620,6 @@ export class BoolArrayProperty extends ValueArrayProperty { for (var i = 0; i < in_length; i++) { this._dataArraySetValue(i, false); } - }; + } } BoolArrayProperty.prototype._typeid = 'Bool'; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/valueMapProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/valueMapProperty.js index 2b6196f157f1..be17e811fbb2 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/valueMapProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/valueMapProperty.js @@ -8,19 +8,17 @@ const _ = require('lodash'); const { MSG } = require('@fluid-experimental/property-common').constants; -const { _castFunctors } = require('./primitiveTypeCasts'); -const { BaseProperty } = require('./baseProperty'); -const { MapProperty } = require('./mapProperty'); const { Int64, Uint64 } = require('@fluid-experimental/property-common'); const { Int64Property, Uint64Property } = require('../properties/intProperties'); const { validationsEnabled } = require('../enableValidations'); - +const { _castFunctors } = require('./primitiveTypeCasts'); +const { BaseProperty } = require('./baseProperty'); +const { MapProperty } = require('./mapProperty'); /** * A ValueMapProperty is a collection class that can contain an dictionary that maps from strings to primitive types. */ export class ValueMapProperty extends MapProperty { - /** * @param {Object} in_params - Input parameters for property creation * @@ -32,7 +30,7 @@ export class ValueMapProperty extends MapProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Inserts a value into the map. Using insert with a key that already exists will throw an error. @@ -44,7 +42,7 @@ export class ValueMapProperty extends MapProperty { insert(in_key, in_value) { var castedValue = this._castFunctor ? this._castFunctor(in_value) : in_value; this._insert(in_key, castedValue, true); - }; + } /** * Returns an object with all the nested values contained in this property @@ -61,7 +59,7 @@ export class ValueMapProperty extends MapProperty { result[ids[i]] = this.get(ids[i]); } return result; - }; + } /** * Return a JSON representation of the map and its items. @@ -74,9 +72,9 @@ export class ValueMapProperty extends MapProperty { context: this._context, typeid: this.getTypeid(), isConstant: this._isConstant, - value: this.getValues() + value: this.getValues(), }; - }; + } /** * Repeatedly calls back the given function with human-readable string @@ -92,10 +90,10 @@ export class ValueMapProperty extends MapProperty { prefix = '"'; suffix = '"'; } - _.mapValues(this._dynamicChildren, function (val, key) { + _.mapValues(this._dynamicChildren, function(val, key) { printFct(indent + key + ': ' + prefix + val + suffix); }); - }; + } /** * Sets the value of a property into the map. @@ -103,15 +101,15 @@ export class ValueMapProperty extends MapProperty { * @param {string} in_key the key under which the entry is set * @param {*} in_value the value to be set */ - set(in_key, in_value) { - if (validationsEnabled.enabled) { - this._checkIsNotReadOnly(true); - } - var castedValue = this._castFunctor ? this._castFunctor(in_value) : in_value; - if (this._dynamicChildren[in_key] !== castedValue) { - if (validationsEnabled.enabled) { - this._checkIsNotReadOnly(true); - } + set(in_key, in_value) { + if (validationsEnabled.enabled) { + this._checkIsNotReadOnly(true); + } + var castedValue = this._castFunctor ? this._castFunctor(in_value) : in_value; + if (this._dynamicChildren[in_key] !== castedValue) { + if (validationsEnabled.enabled) { + this._checkIsNotReadOnly(true); + } if (this._dynamicChildren[in_key] !== undefined) { this._removeByKey(in_key, false); } @@ -119,11 +117,11 @@ export class ValueMapProperty extends MapProperty { // Make one final report this._reportDirtinessToView(); } - }; + } _getValue(in_key) { return this._dynamicChildren[in_key]; - }; + } /** * @inheritdoc @@ -189,8 +187,7 @@ export class ValueMapProperty extends MapProperty { // If working with primitive types, we have to update the dirty flag, when one of the entries // was changed this._setDirty(false); - }; - + } } // The value map contains primitive types ValueMapProperty.prototype._containsPrimitiveTypes = true; @@ -211,7 +208,6 @@ export class Float32MapProperty extends ValueMapProperty { constructor(in_params) { super(in_params); } - } Float32MapProperty.prototype._typeid = 'Float32'; Float32MapProperty.prototype._castFunctor = _castFunctors.Float32; @@ -231,7 +227,7 @@ export class Float64MapProperty extends ValueMapProperty { */ constructor(in_params) { super(in_params); - }; + } } Float64MapProperty.prototype._typeid = 'Float64'; Float64MapProperty.prototype._castFunctor = _castFunctors.Float64; @@ -251,7 +247,7 @@ export class Uint32MapProperty extends ValueMapProperty { */ constructor(in_params) { super(in_params); - }; + } } Uint32MapProperty.prototype._typeid = 'Uint32'; Uint32MapProperty.prototype._castFunctor = _castFunctors.Uint32; @@ -271,7 +267,7 @@ export class Uint16MapProperty extends ValueMapProperty { */ constructor(in_params) { super(in_params); - }; + } } Uint16MapProperty.prototype._typeid = 'Uint16'; Uint16MapProperty.prototype._castFunctor = _castFunctors.Uint16; @@ -291,7 +287,7 @@ export class Uint8MapProperty extends ValueMapProperty { */ constructor(in_params) { super(in_params); - }; + } } Uint8MapProperty.prototype._typeid = 'Uint8'; Uint8MapProperty.prototype._castFunctor = _castFunctors.Uint8; @@ -311,7 +307,7 @@ export class Int32MapProperty extends ValueMapProperty { */ constructor(in_params) { super(in_params); - }; + } } Int32MapProperty.prototype._typeid = 'Int32'; Int32MapProperty.prototype._castFunctor = _castFunctors.Int32; @@ -331,7 +327,7 @@ export class Integer64MapProperty extends ValueMapProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Sets the entry with the given key to the value passed in @@ -353,7 +349,7 @@ export class Integer64MapProperty extends ValueMapProperty { // Make one final report this._reportDirtinessToView(); } - }; + } /** * Function to serialize special primitive types. @@ -365,7 +361,7 @@ export class Integer64MapProperty extends ValueMapProperty { */ _serializeValue(in_obj) { return [in_obj.getValueLow(), in_obj.getValueHigh()]; - }; + } /** * @inheritdoc @@ -373,7 +369,7 @@ export class Integer64MapProperty extends ValueMapProperty { _prettyPrintChildren(indent, printFct) { indent += ' '; var int64Prop; - _.mapValues(this._dynamicChildren, function (val, key) { + _.mapValues(this._dynamicChildren, function(val, key) { // TODO: The 'toString()' function is defined on Integer64Property, so we need to create // such object to use it. It would be better to have it in Utils Integer64.prototype.toString if (val instanceof Int64) { @@ -385,7 +381,7 @@ export class Integer64MapProperty extends ValueMapProperty { int64Prop.setValueHigh(val.getValueHigh()); printFct(indent + key + ': ' + int64Prop); }); - }; + } } /** @@ -403,7 +399,7 @@ export class Int64MapProperty extends Integer64MapProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Specialized function to deserialize Int64 primitive types. @@ -415,8 +411,7 @@ export class Int64MapProperty extends Integer64MapProperty { */ _deserializeValue(in_serializedObj) { return new Int64(in_serializedObj[0], in_serializedObj[1]); - }; - + } } Int64MapProperty.prototype._typeid = 'Int64'; Int64MapProperty.prototype._castFunctor = _castFunctors.Int64; @@ -436,7 +431,7 @@ export class Uint64MapProperty extends Integer64MapProperty { */ constructor(in_params) { super(in_params); - }; + } /** * Specialized function to deserialize Uint64 primitive types. @@ -448,7 +443,7 @@ export class Uint64MapProperty extends Integer64MapProperty { */ _deserializeValue(in_serializedObj) { return new Uint64(in_serializedObj[0], in_serializedObj[1]); - }; + } } Uint64MapProperty.prototype._typeid = 'Uint64'; Uint64MapProperty.prototype._castFunctor = _castFunctors.Uint64; @@ -467,7 +462,7 @@ export class Int16MapProperty extends ValueMapProperty { */ constructor(in_params) { super(in_params); - }; + } } Int16MapProperty.prototype._typeid = 'Int16'; Int16MapProperty.prototype._castFunctor = _castFunctors.Int16; @@ -487,7 +482,7 @@ export class Int8MapProperty extends ValueMapProperty { */ constructor(in_params) { super(in_params); - }; + } } Int8MapProperty.prototype._typeid = 'Int8'; Int8MapProperty.prototype._castFunctor = _castFunctors.Int8; @@ -507,7 +502,7 @@ export class StringMapProperty extends ValueMapProperty { */ constructor(in_params) { super(in_params); - }; + } } StringMapProperty.prototype._typeid = 'String'; StringMapProperty.prototype._castFunctor = _castFunctors.String; @@ -527,7 +522,7 @@ export class BoolMapProperty extends ValueMapProperty { */ constructor(in_params) { super(in_params); - }; + } } BoolMapProperty.prototype._typeid = 'Bool'; BoolMapProperty.prototype._castFunctor = _castFunctors.Boolean; diff --git a/experimental/PropertyDDS/packages/property-properties/src/properties/valueProperty.js b/experimental/PropertyDDS/packages/property-properties/src/properties/valueProperty.js index 9be8aa1d55c4..5936f92e8085 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/properties/valueProperty.js +++ b/experimental/PropertyDDS/packages/property-properties/src/properties/valueProperty.js @@ -2,9 +2,9 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -const { BaseProperty } = require('./baseProperty'); const { ChangeSet } = require('@fluid-experimental/property-changeset'); const { MSG } = require('@fluid-experimental/property-common').constants; +const { BaseProperty } = require('./baseProperty'); /** * This class serves as a view to read, write and listen to changes in an @@ -13,7 +13,6 @@ const { MSG } = require('@fluid-experimental/property-common').constants; * present this property will fail constructing. */ export class ValueProperty extends BaseProperty { - /** * @virtual * @param {Object=} in_params - the parameters @@ -33,8 +32,7 @@ export class ValueProperty extends BaseProperty { constructor(in_params) { super(in_params); this._data = undefined; - }; - + } /** * Is this property a leaf node with regard to flattening? @@ -45,8 +43,7 @@ export class ValueProperty extends BaseProperty { */ _isFlattenLeaf() { return true; - }; - + } /** * returns the current value of ValueProperty @@ -54,7 +51,7 @@ export class ValueProperty extends BaseProperty { */ getValue() { return this._data; - }; + } /** * Ensure the array dirty mask is also cleaned when cleaning the tree. @@ -64,7 +61,7 @@ export class ValueProperty extends BaseProperty { */ cleanDirty(in_flags) { this._cleanDirty(in_flags); - }; + } /** * @param {*} in_value the new value @@ -73,7 +70,7 @@ export class ValueProperty extends BaseProperty { setValue(in_value) { this._checkIsNotReadOnly(true); this._setValue(in_value, true); - }; + } /** * Internal function to update the value of a property @@ -97,7 +94,7 @@ export class ValueProperty extends BaseProperty { this._setDirty(in_reportToView); } return changed; - }; + } /** * @inheritdoc @@ -111,7 +108,7 @@ export class ValueProperty extends BaseProperty { var changed = this._setValue(in_serializedObj, in_reportToView); return changed ? this._data : undefined; } - }; + } /** * @inheritdoc @@ -124,7 +121,7 @@ export class ValueProperty extends BaseProperty { } this._setValue(newVal, in_reportToView); } - }; + } /** * @inheritdoc @@ -137,8 +134,7 @@ export class ValueProperty extends BaseProperty { if (flags) { this._setDirty(false, this, flags); } - }; - + } /** * Serialize the property @@ -168,7 +164,7 @@ export class ValueProperty extends BaseProperty { } else { return this._data; } - }; + } /** * Calls back the given function with a human-readable string @@ -180,7 +176,7 @@ export class ValueProperty extends BaseProperty { */ _prettyPrint(indent, externalId, printFct) { printFct(indent + externalId + this.getId() + ' (' + this.getTypeid() + '): ' + this.value); - }; + } /** * Return a JSON representation of the property. @@ -193,10 +189,9 @@ export class ValueProperty extends BaseProperty { context: this._context, typeid: this.getTypeid(), isConstant: this._isConstant, - value: this.getValue() + value: this.getValue(), }; - }; - + } get value() { return this.getValue.apply(this, arguments); diff --git a/experimental/PropertyDDS/packages/property-properties/src/propertyFactory.js b/experimental/PropertyDDS/packages/property-properties/src/propertyFactory.js index 6741d8cddfc6..405c951cf0b2 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/propertyFactory.js +++ b/experimental/PropertyDDS/packages/property-properties/src/propertyFactory.js @@ -18,7 +18,7 @@ const { EventEmitter, SortedCollection, constants, - GuidUtils + GuidUtils, } = require('@fluid-experimental/property-common'); const { MSG } = constants; @@ -26,9 +26,11 @@ const { TypeIdHelper, TemplateValidator, PathHelper, - ChangeSet + ChangeSet, } = require('@fluid-experimental/property-changeset'); +const semver = require('semver'); +const async = require('async'); const { PropertyTemplate } = require('./propertyTemplate'); const { PropertyTemplateWrapper } = require('./propertyTemplateWrapper'); @@ -49,7 +51,7 @@ const { const { Float32Property, - Float64Property + Float64Property, } = require('./properties/floatProperties'); const { @@ -57,7 +59,7 @@ const { Int16Property, Int32Property, Int64Property, - Uint64Property + Uint64Property, } = require('./properties/intProperties'); const { StringProperty } = require('./properties/stringProperty'); @@ -104,14 +106,11 @@ const { Int16MapProperty, Int8MapProperty, StringMapProperty, - BoolMapProperty + BoolMapProperty, } = require('./properties/valueMapProperty'); -const semver = require('semver'); -const async = require('async'); const { LazyLoadedProperties } = require('./properties/lazyLoadedProperties'); - /** * Creates an instance of the TemplateValidator * @@ -123,13 +122,13 @@ const { LazyLoadedProperties } = require('./properties/lazyLoadedProperties'); * * @ignore */ -var _createTemplateValidator = function (skipSemver) { - var hasSchema = function (typeid) { +var _createTemplateValidator = function(skipSemver) { + var hasSchema = function(typeid) { return this._localVersionedTemplates.has(typeid); }; var params = { inheritsFrom: this.inheritsFrom.bind(this), - hasSchema: hasSchema.bind(this) + hasSchema: hasSchema.bind(this), }; if (skipSemver) { @@ -150,7 +149,7 @@ var _createTemplateValidator = function (skipSemver) { * @throws if no in_template is passed. * @param {property-properties.PropertyTemplate|object} in_template - the template to register. */ -var registerLocal = function (in_template) { +var registerLocal = function(in_template) { var typeid = in_template.typeid; var remoteTemplates = this._getRemoteTemplates(typeid); @@ -179,17 +178,17 @@ var registerLocal = function (in_template) { localValidationResults = templateValidator.validate( localRegisteredTemplate.serializeCanonical(), - serializedInTemplate + serializedInTemplate, ); } if (localValidationResults.isValid) { var remoteValidationResults = { isValid: true }; if (remoteTemplates.length) { - _.every(remoteTemplates, function (template) { + _.every(remoteTemplates, function(template) { remoteValidationResults = templateValidator.validate( template.serializeCanonical(), - serializedInTemplate + serializedInTemplate, ); return remoteValidationResults.isValid; @@ -200,12 +199,12 @@ var registerLocal = function (in_template) { if (!localValidationResults.isValid) { throw new Error( MSG.TEMPLATE_MISMATCH + typeid + - '\n errors = ' + JSON.stringify(_extractErrorMessage(localValidationResults.errors), 0, 2) + '\n errors = ' + JSON.stringify(_extractErrorMessage(localValidationResults.errors), 0, 2), ); } else if (!remoteValidationResults.isValid) { throw new Error( MSG.REMOTE_TEMPLATE_MISMATCH + typeid + - '\n errors = ' + JSON.stringify(_extractErrorMessage(remoteValidationResults.errors), 0, 2) + '\n errors = ' + JSON.stringify(_extractErrorMessage(remoteValidationResults.errors), 0, 2), ); } else if (this._localPrimitivePropertiesAndTemplates.has(typeid)) { // Template is already registered. Do nothing. @@ -232,7 +231,7 @@ var registerLocal = function (in_template) { } else { throw new Error( MSG.FAILED_TO_REGISTER + typeid + - '\n errors = ' + JSON.stringify(_extractErrorMessage(validationResult.errors), 0, 2) + '\n errors = ' + JSON.stringify(_extractErrorMessage(validationResult.errors), 0, 2), ); } } else { @@ -242,7 +241,7 @@ var registerLocal = function (in_template) { this._registerTypeId(typeid, in_template); } else { throw new Error( - MSG.CANNOT_REGISTER_PRIMITIVE + typeid + MSG.CANNOT_REGISTER_PRIMITIVE + typeid, ); } }; @@ -253,8 +252,8 @@ var registerLocal = function (in_template) { * @private * @return {Array.} List of error messages */ -var _extractErrorMessage = function (in_errors) { - return _.map(in_errors, function (error) { +var _extractErrorMessage = function(in_errors) { + return _.map(in_errors, function(error) { return error.message; }); }; @@ -264,9 +263,9 @@ var _extractErrorMessage = function (in_errors) { * @return {property-common.Datastructures.SortedCollection} Empty sorted collection * @private */ -var _createVersionedSortedCollection = function () { +var _createVersionedSortedCollection = function() { var collection = new SortedCollection(); - collection.setComparisonFunction(function (versionA, versionB) { + collection.setComparisonFunction(function(versionA, versionB) { if (semver.gt(versionA, versionB)) { return 1; } else if (semver.lt(versionA, versionB)) { @@ -286,11 +285,11 @@ var _createVersionedSortedCollection = function () { * * @return {Array} list of unknown typeids */ -var _extractUnknownDependencies = function (in_template) { +var _extractUnknownDependencies = function(in_template) { var self = this; var dependencies = PropertyTemplate.extractDependencies(in_template); - dependencies = dependencies.filter(function (typeid) { + dependencies = dependencies.filter(function(typeid) { return !self._localPrimitivePropertiesAndTemplates.has(typeid); }); @@ -304,7 +303,7 @@ var _extractUnknownDependencies = function (in_template) { * @param {String} in_typeid typeid of the template to retrieve * */ -var _pushTemplateRequestTask = function (in_typeid) { +var _pushTemplateRequestTask = function(in_typeid) { var that = this; if (that.missingDependencies[in_typeid].requested === true) { @@ -312,7 +311,7 @@ var _pushTemplateRequestTask = function (in_typeid) { } that.missingDependencies[in_typeid].requested = true; - this.templateRequestsQueue.push({ typeid: in_typeid, context: that._templateStore }, function (response) { + this.templateRequestsQueue.push({ typeid: in_typeid, context: that._templateStore }, function(response) { if (response.error) { that.templateRequestsResults.errors[in_typeid] = response.error; } else { @@ -388,7 +387,7 @@ class PropertyFactory { // Structure containing results the process of retrieving property set schemas from store this.templateRequestsResults = { errors: {}, - schemas: {} + schemas: {}, }; // Cache of inheritsFrom() request results @@ -409,7 +408,7 @@ class PropertyFactory { this._forceInstantion = false; this._init(); - }; + } /** * Add a listener for a given type of event. @@ -422,7 +421,7 @@ class PropertyFactory { */ addListener(eventName, eventListener) { this._eventEmitter.addListener(eventName, eventListener); - }; + } /** * Remove a listener for a given type of event. Iff a listener was removed, @@ -432,10 +431,10 @@ class PropertyFactory { * listener was attached. * @param {function} eventListener The function to remove from the list of functions * @public - **/ + * */ removeListener(eventName, eventListener) { this._eventEmitter.removeListener(eventName, eventListener); - }; + } /** * Initialize the PropertyFactory by registering primitive types @@ -497,27 +496,27 @@ class PropertyFactory { var NamedPropertyTemplate = { typeid: 'NamedProperty', properties: [ - { id: 'guid', typeid: 'String' } - ] + { id: 'guid', typeid: 'String' }, + ], }; var NamedNodePropertyTemplate = { typeid: 'NamedNodeProperty', - inherits: ['NodeProperty', 'NamedProperty'] + inherits: ['NodeProperty', 'NamedProperty'], }; var RelationshipPropertyTemplate = { typeid: 'RelationshipProperty', inherits: ['NodeProperty', 'NamedProperty'], properties: [ - { id: 'to', typeid: 'Reference' } - ] + { id: 'to', typeid: 'Reference' }, + ], }; this._registerTypeId(NamedPropertyTemplate.typeid, NamedPropertyTemplate); this._registerTypeId(NamedNodePropertyTemplate.typeid, NamedNodePropertyTemplate); this._registerTypeId(RelationshipPropertyTemplate.typeid, RelationshipPropertyTemplate); - }; + } /** * Register a template which are used to instantiate properties. To find out more about templates, @@ -532,7 +531,6 @@ class PropertyFactory { * @param {property-properties.PropertyTemplate|object|String|Array} in_input - a template, a typeid or an array of either */ register(in_input) { - if (this.missingDependencies === undefined) { this.missingDependencies = {}; } @@ -551,8 +549,8 @@ class PropertyFactory { // 3. in_input is an array of strings (typeids) or jsons // apply step 1. or 2. for all elements of array - var validateArray = function (array) { - var isInvalid = _.some(array, function (value) { + var validateArray = function(array) { + var isInvalid = _.some(array, function(value) { return !PropertyTemplate.isTemplate(value) && !TypeIdHelper.isTemplateTypeid(value); }); @@ -588,7 +586,7 @@ class PropertyFactory { delete this.missingDependencies[elem]; } } - }; + } /** * Recursively parses the object of the specified type and returns the created @@ -608,7 +606,7 @@ class PropertyFactory { default: throw new Error(MSG.UNKNOWN_TYPE + in_fromType); } - }; + } /** * Recursively parses the object of the specified type and registers the created @@ -627,7 +625,7 @@ class PropertyFactory { for (var i = 0; i < psetsTemplates.length; i++) { this.register(psetsTemplates[i]); } - }; + } /** * Validate semver. @@ -672,7 +670,7 @@ class PropertyFactory { if (in_compareRemote) { var that = this; - this._remoteScopedAndVersionedTemplates.iterate(function (scope, remoteVersionedTemplates) { + this._remoteScopedAndVersionedTemplates.iterate(function(scope, remoteVersionedTemplates) { if (remoteVersionedTemplates.has(typeidWithoutVersion)) { var previousRemoteVersion = remoteVersionedTemplates.item(typeidWithoutVersion) .getNearestPreviousItem(version); @@ -680,7 +678,7 @@ class PropertyFactory { if (previousRemoteVersion) { validationResults = that._templateValidator.validate( in_template.serializeCanonical(), - previousRemoteVersion.getPropertyTemplate().serializeCanonical() + previousRemoteVersion.getPropertyTemplate().serializeCanonical(), ); warnings.push.apply(warnings, validationResults.warnings); } else { @@ -688,7 +686,7 @@ class PropertyFactory { if (nextRemoteVersion) { validationResults = that._templateValidator.validate( nextRemoteVersion.getPropertyTemplate().serializeCanonical(), - in_template.serializeCanonical() + in_template.serializeCanonical(), ); warnings.push.apply(warnings, validationResults.warnings); } @@ -700,10 +698,10 @@ class PropertyFactory { if (!_.isEmpty(warnings)) { console.warn( 'Template with typeid = ' + typeid + - ' is valid but with the following warnings = ' + JSON.stringify(warnings, 0, 2) + ' is valid but with the following warnings = ' + JSON.stringify(warnings, 0, 2), ); } - }; + } /** * Internal method used to register remote templates coming over the wire. @@ -731,12 +729,12 @@ class PropertyFactory { var templateValidator = _createTemplateValidator.call(this); var validationResults = templateValidator.validate( registeredTemplate.serializeCanonical(), - in_remoteTemplate.serializeCanonical() + in_remoteTemplate.serializeCanonical(), ); if (!validationResults.isValid) { throw new Error( MSG.TEMPLATE_MISMATCH + typeid + - '\n errors = ' + JSON.stringify(_extractErrorMessage(validationResults.errors), 0, 2) + '\n errors = ' + JSON.stringify(_extractErrorMessage(validationResults.errors), 0, 2), ); } } else if (in_remoteTemplate._isVersioned()) { @@ -765,7 +763,7 @@ class PropertyFactory { } else { throw new Error(MSG.UNVERSIONED_REMOTE_TEMPLATE + ' \n' + JSON.stringify(in_remoteTemplate, 0, 2)); } - }; + } /** * Remove the scope from the remote templates collection @@ -777,15 +775,15 @@ class PropertyFactory { if (this._remoteScopedAndVersionedTemplates.has(in_scope)) { // remove the schemas in this scope from the inheritance cache. - this._remoteScopedAndVersionedTemplates.item(in_scope).iterate(function (nt, schemas) { - schemas.iterate(function (k, schema) { + this._remoteScopedAndVersionedTemplates.item(in_scope).iterate(function(nt, schemas) { + schemas.iterate(function(k, schema) { delete that._inheritanceCache[schema.getPropertyTemplate().typeid]; }); }); this._remoteScopedAndVersionedTemplates.remove(in_scope); } - }; + } /** * Triggered when a template is registered. @@ -793,7 +791,7 @@ class PropertyFactory { * @param {property-properties.Template} Template - The template being registered. * @memberof property-properties.PropertyFactory * - **/ + * */ /** * Register a template or a primitive property @@ -834,7 +832,7 @@ class PropertyFactory { } this._eventEmitter.emit('registered', in_templateOrProperty); - }; + } /** * Validate a template @@ -857,7 +855,7 @@ class PropertyFactory { */ validate(in_template) { return this._templateValidator.validate(in_template); - }; + } /** * Get a template or property object based on a typeid and a context @@ -875,7 +873,7 @@ class PropertyFactory { return templateOrProperty.getPropertyTemplate(); } return templateOrProperty; - }; + } /** * Get a template or property object based on a typeid and a context @@ -910,7 +908,7 @@ class PropertyFactory { } return undefined; - }; + } /** * Get template based on typeid @@ -921,8 +919,10 @@ class PropertyFactory { getTemplate(in_typeid) { if (this._localPrimitivePropertiesAndTemplates.has(in_typeid) && !TypeIdHelper.isPrimitiveType(in_typeid)) { return this._localPrimitivePropertiesAndTemplates.item(in_typeid).getPropertyTemplate(); - } else return undefined; - }; + } else { + return undefined; + } + } /** * Get remote templates based on typeid @@ -937,16 +937,15 @@ class PropertyFactory { var typeidWithoutVersion = parsedTypeId.typeidWithoutVersion; var version = parsedTypeId.version; - this._remoteScopedAndVersionedTemplates.iterate(function (scope, remoteVersionedTemplates) { + this._remoteScopedAndVersionedTemplates.iterate(function(scope, remoteVersionedTemplates) { if (remoteVersionedTemplates.has(typeidWithoutVersion) && remoteVersionedTemplates.item(typeidWithoutVersion).item(version)) { - templatesFound.push(remoteVersionedTemplates.item(typeidWithoutVersion).item(version).getPropertyTemplate()); } }); return templatesFound; - }; + } /** * Create an instance of the given property typeid if there is a template registered for it. @@ -962,7 +961,6 @@ class PropertyFactory { */ _createProperty( in_typeid, in_context, in_initialProperties, in_scope) { - const ifNotSingleOrUndefined = (in_context || 'single') !== 'single'; ConsoleUtils.assert(ifNotSingleOrUndefined || _.isString(in_typeid), MSG.UNKNOWN_TYPEID_SPECIFIED + in_typeid); let context = in_context; @@ -992,7 +990,7 @@ class PropertyFactory { propertyDef = {}; this._createDefFromPropertyDeclaration({ typeid: in_typeid, - context: context || 'single' + context: context || 'single', }, in_scope, propertyDef); } @@ -1009,18 +1007,18 @@ class PropertyFactory { // default initialized property if (in_initialProperties !== undefined) { this._setInitialValue(property, { - value: in_initialProperties + value: in_initialProperties, }, false); } } else { // Directly instantiate the property from the definition (without using) a precompield function property = this._instantiatePropertyDef(propertyDef, in_scope, in_initialProperties && { - value: in_initialProperties + value: in_initialProperties, }); } return property; - }; + } /** * Creates an instance of the property described in the property definition. @@ -1042,7 +1040,7 @@ class PropertyFactory { const creationStack = [{ id: undefined, entry: propertyDef, - parent:undefined + parent:undefined, }]; while (creationStack.length > 0) { @@ -1094,8 +1092,8 @@ class PropertyFactory { const parentStackEntry = { signalChildrenFinished: true, initialValue: currentEntry.entry.initialValue, - property - } + property, + }; creationStack.push(parentStackEntry); for (let [id, child] of currentEntry.entry.children) { @@ -1104,8 +1102,8 @@ class PropertyFactory { id: id, entry: child, setGuid: currentEntry.entry.assignGuid && id === - 'guid' - }) + 'guid', + }); } } else { // If there are no children, we directly assign the initial value and @@ -1138,12 +1136,11 @@ class PropertyFactory { * @returns {Function} A function that creates an instance of the property */ _definePropertyCreationFunction(propertyDef, in_typeid, in_scope, in_context) { - // This stack is used to recursively iterate over the property definition const creationStack = [{ id: null, def: propertyDef, - parent:undefined + parent:undefined, }]; let creationFunctionSource = ""; @@ -1179,7 +1176,6 @@ class PropertyFactory { // chain can overwrite entries further down while (parentEntry) { if (parentEntry.initialValue) { - // Extract changes to be applied to this property let filteredChangeSet = parentEntry.initialValue.value; for (let i = 0; i < path.length; i++) { @@ -1191,7 +1187,7 @@ class PropertyFactory { if (initialValue === undefined) { initialValue = { typed: false, - value: filteredChangeSet + value: filteredChangeSet, }; } else if (_.isObject(initialValue)) { Object.assign(initialValue.value, filteredChangeSet); @@ -1202,8 +1198,8 @@ class PropertyFactory { if (initialValue === undefined) { initialValue = { value: undefined, - typed: false - } + typed: false, + }; } initialValue.value = filteredChangeSet; } @@ -1215,7 +1211,6 @@ class PropertyFactory { } } - if (currentEntry.def.constant) { // If we have a constant property, we create a concrete property object instance and share it // among all instances of the parent property @@ -1240,11 +1235,9 @@ class PropertyFactory { parameters.push(instantiatedChild); creationFunctionSource += `${currentEntry.parentVarName}._append( parameters[${currentParameterIndex}], ${currentEntry.def.allowChildMerges} - );\n` + );\n`; currentParameterIndex += 1; } else { - - // Put the constructor function and the description of the property into the // parameters array parameters.push(currentEntry.def.constructorFunction); @@ -1263,11 +1256,11 @@ class PropertyFactory { if (currentEntry.def.optional) { creationFunctionSource += `${currentEntry.parentVarName}._insert( ${JSON.stringify(currentEntry.def.entry.id)}, ${currentPropertyVarName}, true - );\n` + );\n`; } else { creationFunctionSource += `${currentEntry.parentVarName}._append( ${currentPropertyVarName}, ${currentEntry.def.allowChildMerges} - );\n` + );\n`; } } else { resultVarName = currentPropertyVarName; @@ -1275,7 +1268,7 @@ class PropertyFactory { // For named properties we have to add a calll to assign a GUID to the function if (currentEntry.setGuid) { - creationFunctionSource += `${currentPropertyVarName}.value = GuidUtils.generateGUID();\n` + creationFunctionSource += `${currentPropertyVarName}.value = GuidUtils.generateGUID();\n`; } // And if there are any optional children, we add them here (should this be further optimized? I @@ -1285,7 +1278,7 @@ class PropertyFactory { creationFunctionSource += `${currentPropertyVarName}._addOptionalChild( ${JSON.stringify(id)}, ${JSON.stringify(typeid)} - );\n` + );\n`; } } @@ -1310,7 +1303,7 @@ class PropertyFactory { def: child, signalParent: false, setGuid: currentEntry.def.assignGuid && id === 'guid', - parentStackEntry + parentStackEntry, }); } } else { @@ -1320,7 +1313,7 @@ class PropertyFactory { if (!_.isObject(initialValue.value)) { // We have a primitive property and thus direclty invoke the setValue function creationFunctionSource += - `${currentPropertyVarName}.setValue(${JSON.stringify(initialValue.value)});\n` + `${currentPropertyVarName}.setValue(${JSON.stringify(initialValue.value)});\n`; } else { // For non primitive properties, we currently use the member on the property factory, // probably we could further optimize this to directly call the correct function on the @@ -1334,14 +1327,14 @@ class PropertyFactory { // If this property is constant, we assign the constant flag if (currentEntry.def.constant) { - creationFunctionSource += `${currentPropertyVarName}._setAsConstant();\n` + creationFunctionSource += `${currentPropertyVarName}._setAsConstant();\n`; } // If necessary, signal that the propert has been fully initialized (is this ever needed?) if (currentEntry.def.signal) { creationFunctionSource += `${currentPropertyVarName}._signalAllStaticMembersHaveBeenAdded( ${JSON.stringify(in_scope)} - );\n` + );\n`; } } } @@ -1395,7 +1388,7 @@ class PropertyFactory { } else { property._setValues(valueParsed.value, false, true); } - }; + } /** * Create an instance of the given property typeid if there is a template registered for it. @@ -1411,7 +1404,7 @@ class PropertyFactory { */ create(in_typeid, in_context, in_initialProperties) { return this._createProperty(in_typeid, in_context, in_initialProperties, null); - }; + } /** * Creates a constructor function for the given typeid and id. The function will inherit from the @@ -1455,7 +1448,7 @@ class PropertyFactory { // sure whether we want to use a dynamic eval for this. It might be flagged by some security scans // It should be safe, since we control the name of constructorClasses for properties // eslint-disable-next-line no-new-func - var propertyConstructorFunction = class extends in_baseConstructor { } + var propertyConstructorFunction = class extends in_baseConstructor { }; propertyConstructorFunction.prototype._typeid = in_typeid; Object.defineProperty(propertyConstructorFunction, 'name', { value: in_baseConstructor.name }); @@ -1467,7 +1460,7 @@ class PropertyFactory { this._typedPropertyConstructorCache[key] = propertyConstructorFunction; return propertyConstructorFunction; - }; + } /** * Creates a property definition for a non-collection property with the entry and constructor function assigned @@ -1484,11 +1477,10 @@ class PropertyFactory { */ _createNonCollectionPropertyDef(in_typeid, in_id, in_templateOrConstructor, in_scope, propertyDef) { - let ConstructorFunction; const params = { typeid: in_typeid, - id: in_id + id: in_id, }; if (this.inheritsFrom(in_typeid, 'NamedProperty', { scope: in_scope })) { @@ -1524,7 +1516,7 @@ class PropertyFactory { propertyDef.entry = params; propertyDef.context = 'single'; propertyDef.typeid = in_typeid; - }; + } /** * Check whether a typeid is registered @@ -1535,7 +1527,7 @@ class PropertyFactory { */ _isRegisteredTypeid(in_typeid, in_scope) { return !!this._get(in_typeid, undefined, in_scope); - }; + } /** * Checks if there exists a registered template with a corresponding typeid @@ -1559,7 +1551,7 @@ class PropertyFactory { } return registered; - }; + } /** * Check whether the given typeid is a specialized constructor @@ -1570,7 +1562,7 @@ class PropertyFactory { */ _isSpecializedConstructor(in_typeid) { return this._localPrimitivePropertiesAndTemplates.item(in_typeid) instanceof Collection; - }; + } /** * Generate the typeid according to multiple settings @@ -1603,7 +1595,7 @@ class PropertyFactory { typeid = 'Reference'; } return typeid; - }; + } /** * Creates a propertyDef for the given properties entry @@ -1619,7 +1611,6 @@ class PropertyFactory { * @param {Object} out_propertyDef - The created property definition */ _createDefFromPropertyDeclaration(in_propertiesEntry, in_scope, out_propertyDef) { - var context = in_propertiesEntry.context !== undefined ? in_propertiesEntry.context : 'single'; var typeid = this._computeTypeid(in_propertiesEntry, in_scope, context); var referenceTarget = typeid === 'Reference' ? @@ -1662,7 +1653,7 @@ class PropertyFactory { in_propertiesEntry.id, templateOrConstructor, in_scope, - out_propertyDef + out_propertyDef, ); this._parseTemplate(templateOrConstructor, in_scope, @@ -1683,7 +1674,6 @@ class PropertyFactory { constructorFunction = EnumArrayProperty; } else { - constructorFunction = ArrayProperty; } break; @@ -1738,7 +1728,7 @@ class PropertyFactory { if (typeid && this.inheritsFrom(typeid, 'NamedProperty', { scope: in_scope })) { out_propertyDef.assignGuid = true; } - }; + } /** * Method used to determine whether the given object is a property constructor @@ -1751,7 +1741,7 @@ class PropertyFactory { // TODO: This tests seems dangerous. I think it is based on the assumption that constructor is not // overwritten in the derived classes (which it probably should be) return (in_obj.constructor && in_obj.constructor === ContainerProperty.constructor); - }; + } /** * Checks whether the property has a typedValue and replaces the value and the typeid @@ -1767,7 +1757,7 @@ class PropertyFactory { var res = { typed: false, value: in_property.value, - typeid: in_property.typeid + typeid: in_property.typeid, }; if (in_property.typedValue) { @@ -1797,7 +1787,7 @@ class PropertyFactory { } return res; - }; + } /** * Parse a given property template appending its property and constant objects to the given propertyDef @@ -1810,7 +1800,6 @@ class PropertyFactory { * @private */ _parseTemplate(in_template, in_scope, in_allowChildMerges, propertyDef) { - // Check if there are nested property arrays if (!(in_template.inherits && in_template.inherits.indexOf('Enum') !== -1)) { if (in_template.properties) { @@ -1834,7 +1823,7 @@ class PropertyFactory { const newChildEntry = { initialValue: valueParsed, optional, - allowChildMerges: in_allowChildMerges + allowChildMerges: in_allowChildMerges, }; propertyDef.children = propertyDef.children || []; propertyDef.children.unshift([properties[i].id, newChildEntry]); @@ -1842,13 +1831,12 @@ class PropertyFactory { in_scope, newChildEntry); } else if (!optional) { const newChildEntry = { - initialValue: undefined + initialValue: undefined, }; - propertyDef.children = propertyDef.children || [] + propertyDef.children = propertyDef.children || []; propertyDef.children.unshift([properties[i].id, newChildEntry]); this._createDefFromPropertyDeclaration(properties[i], in_scope, newChildEntry); - } } } @@ -1861,7 +1849,7 @@ class PropertyFactory { const newChildEntry = { initialValue: undefined, - constant: true + constant: true, }; propertyDef.children = propertyDef.children || []; propertyDef.children.unshift([constants[i].id, newChildEntry]); @@ -1874,7 +1862,7 @@ class PropertyFactory { } } } - }; + } // private params: // @param {string} [in_options.scope] - The scope in which the property typeid is defined @@ -1925,7 +1913,7 @@ class PropertyFactory { return parents[in_baseTypeid] !== undefined; } - }; + } // private params: // @param {string|undefined} [in_options.scope] - The scope in which the template was stored. @@ -1955,7 +1943,7 @@ class PropertyFactory { this._getAllParentsForTemplateInternal(in_typeid, parents, !!in_options.includeBaseProperty, scope); return _.keys(parents); - }; + } /** * Returns all the typeids the template inherits from (including all possible paths through multiple inheritance). @@ -2004,7 +1992,7 @@ class PropertyFactory { this._getAllParentsForTemplateInternal(parents[i], out_parents, undefined, in_scope); } } - }; + } /** * Internal function used to clear and reinitialize the PropertyFactory @@ -2018,7 +2006,7 @@ class PropertyFactory { this._typedPropertyConstructorCache = {}; this._init(); - }; + } /** * Reregisters a template (by overwriting the existing template). @@ -2064,7 +2052,7 @@ class PropertyFactory { // And repeat the registration registerLocal.call(this, in_template); - }; + } /** * Initializes the schema store. @@ -2076,7 +2064,7 @@ class PropertyFactory { * * @return {Promise} Return an empty promise when checkout resolve or reject with error. */ - initializeSchemaStore(in_options) { + async initializeSchemaStore(in_options) { // https://regex101.com/r/TlgGJp/2 var regexBaseUrl = /^(https?:)?\/\/((.[-a-zA-Z0-9@:%_+~#=.]{2,256}){1,2}\.[a-z]{2,6}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(:\d{1,5})?(\/[-a-zA-Z0-9@:%_+.~#?&/=]*)*$/; // eslint-disable-line max-len @@ -2095,7 +2083,7 @@ class PropertyFactory { this._templateStore = new ForgeSchemaStore(in_options); return Promise.resolve(); - }; + } /** * Pushes a template request task onto the template requests queue @@ -2108,15 +2096,15 @@ class PropertyFactory { _retrieveTemplateRequestWorker(in_task, in_callback) { var store = in_task.context; if (store) { - store.retrieveTemplate(in_task.typeid).then(function (response) { + store.retrieveTemplate(in_task.typeid).then(function(response) { in_callback(response); - }).catch(function (error) { + }).catch(function(error) { in_callback({ error: error }); }); } else { throw new Error(MSG.INVALID_TEMPLATE_STORE); } - }; + } /** * Tries to resolve dependencies after some calls to register() have been made @@ -2138,7 +2126,7 @@ class PropertyFactory { * } * */ - resolveSchemas() { + async resolveSchemas() { // Only one queue at a time can be processed. if (this.templateRequestsQueue !== undefined) { return Promise.reject(new Error(MSG.DEPENDENCIES_RESOLUTION_IN_PROGRESS)); @@ -2149,7 +2137,7 @@ class PropertyFactory { var that = this; // 0. Inspect locally registered templates for unknown dependencies - this._localPrimitivePropertiesAndTemplates.iterate(function (key, type) { + this._localPrimitivePropertiesAndTemplates.iterate(function(key, type) { if (!that._isSpecializedConstructor(key) && PropertyTemplate.isTemplate(type.getPropertyTemplate())) { var unknownDeps = _extractUnknownDependencies.call(that, type.getPropertyTemplate()); for (var d = 0; d < unknownDeps.length; d++) { @@ -2177,12 +2165,12 @@ class PropertyFactory { _pushTemplateRequestTask.call(that, typeid); } - return new Promise(function (resolve, reject) { + return new Promise(function(resolve, reject) { if (that.templateRequestsQueue.length() === 0) { resolve({ errors: {}, schemas: {} }); that.templateRequestsQueue = undefined; } else { - that.templateRequestsQueue.drain = function () { + that.templateRequestsQueue.drain = function() { var errors = _.compact(_.pluck(that.templateRequestsResults.errors, 'typeid')); var results = that.templateRequestsResults; var resultsKeys = Object.keys(that.templateRequestsResults.schemas); @@ -2241,7 +2229,7 @@ class PropertyFactory { }; } }); - }; + } /** * Determines whether the given property is an instance of the property type corresponding to the given native @@ -2260,8 +2248,7 @@ class PropertyFactory { result = in_property instanceof templateConstructor; } return result; - }; - + } } const PropertyFactorySingleton = new PropertyFactory(); diff --git a/experimental/PropertyDDS/packages/property-properties/src/propertyTemplate.js b/experimental/PropertyDDS/packages/property-properties/src/propertyTemplate.js index 2d37c017ca7c..b6f96ae4175a 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/propertyTemplate.js +++ b/experimental/PropertyDDS/packages/property-properties/src/propertyTemplate.js @@ -76,15 +76,15 @@ export class PropertyTemplate { // check for inlined enums and parse them: this._digestNestedInlineEnumProperties(this); this._serializedParams = in_params; - }; + } hasNestedProperties() { return (this.properties && this.properties.length > 0); - }; + } hasNestedConstants() { return (this.constants && this.constants.length > 0); - }; + } /** * internal function to recursivly traverse a property template and create dictionaries for found inline enums @@ -102,7 +102,7 @@ export class PropertyTemplate { } } } - }; + } /** * read the enum types list of a template and create a dictionary [value->enum] and [enum->value] for it @@ -133,7 +133,7 @@ export class PropertyTemplate { } return enumDictionary; - }; + } /** * Clones the PropertyTemplate @@ -142,7 +142,7 @@ export class PropertyTemplate { */ clone() { return new PropertyTemplate(deepCopy(this._serializedParams)); - }; + } /** * Method used to check whether the template is versioned. @@ -159,7 +159,7 @@ export class PropertyTemplate { var version = splitTypeId.version; return /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(version); - }; + } /** * Return the version number of the template. @@ -174,7 +174,7 @@ export class PropertyTemplate { console.warn(MSG.TEMPLATE_NOT_VERSIONED, this.typeid); return undefined; } - }; + } /** * Canonical representation of a PropertyTemplate. @@ -196,7 +196,6 @@ export class PropertyTemplate { * @return {string} The version string is returned. */ _canonicalForm(in_obj, in_target_, in_key_, in_preserve_) { - in_preserve_ = in_preserve_ === undefined ? false : in_preserve_; var target, copyMembers; @@ -220,12 +219,11 @@ export class PropertyTemplate { (_.isArray(in_obj) !== _.isArray(target)) || !_.isObject(target)) { throw new Error( - MSG.INVALID_TARGET_PROPERTY_TEMPLATE + this.typeid + MSG.INVALID_TARGET_PROPERTY_TEMPLATE + this.typeid, ); } copyMembers = true; copyDirectlyIntoKey = true; - } else { // If no existing target object, we create a new object. @@ -244,7 +242,7 @@ export class PropertyTemplate { copyMembers = true; } else { throw new Error( - MSG.MISSING_CASE_IN_TEMPLATE_SERIALIZATION + this.typeid + MSG.MISSING_CASE_IN_TEMPLATE_SERIALIZATION + this.typeid, ); } } @@ -282,7 +280,7 @@ export class PropertyTemplate { } return in_target_; - }; + } /** * Return the serialized parameters passed in the constructor @@ -290,7 +288,7 @@ export class PropertyTemplate { */ serialize() { return deepCopy(this._serializedParams); - }; + } /** * Return the serialized parameters passed in the constructor, in a template canonical form @@ -298,7 +296,7 @@ export class PropertyTemplate { */ serializeCanonical() { return PropertyTemplate.prototype._canonicalForm(this._serializedParams); - }; + } /** * Return the typeid of the template without the version number @@ -313,7 +311,7 @@ export class PropertyTemplate { } else { return this.typeid; } - }; + } /** * Determines if the argument is a template structure @@ -328,7 +326,7 @@ export class PropertyTemplate { return true; } return false; - }; + } /** * Extracts typeids directly referred to in a template @@ -415,6 +413,5 @@ export class PropertyTemplate { } return Object.keys(dependencies); - }; - + } } diff --git a/experimental/PropertyDDS/packages/property-properties/src/propertyTemplateWrapper.js b/experimental/PropertyDDS/packages/property-properties/src/propertyTemplateWrapper.js index ca0cb54cb95b..6db2fcd63b3b 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/propertyTemplateWrapper.js +++ b/experimental/PropertyDDS/packages/property-properties/src/propertyTemplateWrapper.js @@ -8,15 +8,15 @@ * Declaration of the PropertyTemplateWrapper module * PropertyTemplateWrapper is used to wrap a property template and perform internal optimizations */ +const { MSG } = require('@fluid-experimental/property-common').constants; const _ = require('lodash'); const { ContainerProperty } = require('./properties/containerProperty'); -const { MSG } = require('@fluid-experimental/property-common').constants; const reservedTypesWithoutTemplates = { 'BaseProperty': true, 'ContainerProperty': true, 'NodeProperty': true, - 'Enum': true + 'Enum': true, }; /** * Utility function that validates if the typeid is a reserved type without a template. @@ -28,7 +28,6 @@ const hasAssociatedTemplate = (in_typeid) => { }; export class PropertyTemplateWrapper { - /** * Constructor for creating a PropertyTemplateWrapper based on the given template. * @param {PropertyTemplate} in_remoteTemplate A property template @@ -48,13 +47,12 @@ export class PropertyTemplateWrapper { */ this._compiledPropertyTemplate = undefined; - /* What type of base object is created for this template*/ + /* What type of base object is created for this template */ this._objectCreationType = undefined; - /* The scope of this template*/ + /* The scope of this template */ this._scope = in_scope; - }; - + } /** * To get the property template that this is wrapping. @@ -63,7 +61,7 @@ export class PropertyTemplateWrapper { */ getPropertyTemplate() { return this._propertyTemplate; - }; + } /** * Gets the compiled template or creates it then returns it. @@ -78,7 +76,7 @@ export class PropertyTemplateWrapper { this._compiledPropertyTemplate = this._contructCompiledTemplate(in_propertyFactory); } return this._compiledPropertyTemplate; - }; + } /** * Returns if the compiled template has been created. @@ -87,7 +85,7 @@ export class PropertyTemplateWrapper { */ hasCompiledTemplate() { return !!this._compiledPropertyTemplate; - }; + } /** * To get the creation type of the template this wraps. @@ -96,7 +94,7 @@ export class PropertyTemplateWrapper { */ getCreationType() { return this._objectCreationType; - }; + } /** * If current creation type is undefined, sets it to in_typeid if in_typeid is a creation type. @@ -121,7 +119,7 @@ export class PropertyTemplateWrapper { throw new Error(MSG.ONLY_ONE_CREATION_TYPE + currentCreationType + ', ' + in_typeid); } } - }; + } /** * Contructs the compiled template from the template this wraps @@ -250,7 +248,7 @@ export class PropertyTemplateWrapper { } return template; - }; + } /** * A helper function which merges a child and parent property. @@ -325,5 +323,5 @@ export class PropertyTemplateWrapper { mergeSubProperties(in_childProperty, in_parentProperty, 'properties'); mergeSubProperties(in_childProperty, in_parentProperty, 'constants'); - }; + } } diff --git a/experimental/PropertyDDS/packages/property-properties/src/propertyUtils.js b/experimental/PropertyDDS/packages/property-properties/src/propertyUtils.js index 8151bf35e4fa..80bd5b607f66 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/propertyUtils.js +++ b/experimental/PropertyDDS/packages/property-properties/src/propertyUtils.js @@ -4,7 +4,6 @@ */ export class PropertyUtils { - /** * Gather all properties that pass an arbitrary predicate function * @param {property-properties.NodeProperty} in_rootProperty The root property to traverse from @@ -12,9 +11,9 @@ export class PropertyUtils { * @return {Array.} The list of properties that passed the predicate * function */ - static gatherProperties = function (in_rootProperty, in_predicate) { + static gatherProperties = function(in_rootProperty, in_predicate) { var gatheredProperties = {}; - in_rootProperty.traverseDown(function (property, path) { + in_rootProperty.traverseDown(function(property, path) { if (in_predicate(property)) { gatheredProperties[path] = property; } @@ -22,5 +21,4 @@ export class PropertyUtils { return gatheredProperties; }; - } diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/arrayProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/arrayProperty.spec.js index 76b20387f1c1..f44027265fa6 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/arrayProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/arrayProperty.spec.js @@ -10,13 +10,12 @@ * described in /src/properties/baseProperty.js */ - -_ = require('lodash'); -const { PropertyFactory } = require('../..'); -const { BaseProperty } = require('../..'); const { ChangeSet } = require('@fluid-experimental/property-changeset'); const { MSG } = require('@fluid-experimental/property-common').constants; const { DeterministicRandomGenerator, HashCalculator } = require("@fluid-experimental/property-common"); +_ = require('lodash'); +const { PropertyFactory } = require('../..'); +const { BaseProperty } = require('../..'); const deepCopy = _.cloneDeep; const { PATH_TOKENS } = BaseProperty; @@ -29,10 +28,10 @@ var conflicts; var possibleChanges = { 0: 'insert', 1: 'modify', - 2: 'remove' + 2: 'remove', }; -var getRandomNumbersArray = function (in_size, randomGenerator) { +var getRandomNumbersArray = function(in_size, randomGenerator) { var result = []; for (var i = 0; i < in_size; i++) { result.push(Math.floor(randomGenerator.random() * 100)); @@ -40,7 +39,7 @@ var getRandomNumbersArray = function (in_size, randomGenerator) { return result; }; -var compareArrays = function (ap1, ap2) { +var compareArrays = function(ap1, ap2) { if (ap1.length !== ap2.length) { return false; } @@ -55,57 +54,57 @@ var compareArrays = function (ap1, ap2) { var TestArrayFloat32 = { typeid: 'autodesk.test:test.arrayfloat32-1.0.0', properties: [ - { id: 'data', typeid: 'Float32', context: 'array', length: 3 } - ] + { id: 'data', typeid: 'Float32', context: 'array', length: 3 }, + ], }; var TestArrayString = { typeid: 'autodesk.test:test.arraystring-1.0.0', properties: [ - { id: 'data', typeid: 'String', context: 'array', length: 3 } - ] + { id: 'data', typeid: 'String', context: 'array', length: 3 }, + ], }; var TestArrayBool = { typeid: 'autodesk.test:test.arraybool-1.0.0', properties: [ - { id: 'data', typeid: 'Bool', context: 'array', length: 3 } - ] + { id: 'data', typeid: 'Bool', context: 'array', length: 3 }, + ], }; var TestString = { typeid: 'autodesk.test:test.string-1.0.0', properties: [ - { id: 'data', typeid: 'String' } - ] + { id: 'data', typeid: 'String' }, + ], }; var TestCustomArray = { typeid: 'autodesk.test:test.customarray-1.0.0', properties: [ - { id: 'data', typeid: 'autodesk.test:test.string-1.0.0', context: 'array', length: 3 } - ] + { id: 'data', typeid: 'autodesk.test:test.string-1.0.0', context: 'array', length: 3 }, + ], }; var TestDynamicLengthArray = { typeid: 'autodesk.test:test.dynamicArray-1.0.0', properties: [ - { id: 'data', typeid: 'Int32', context: 'array' } - ] + { id: 'data', typeid: 'Int32', context: 'array' }, + ], }; var TestDynamicLengthNonPrimitiveArray = { typeid: 'autodesk.test:test.nonPrimitiveArray-1.0.0', properties: [ - { id: 'data', typeid: 'autodesk.test:test.string-1.0.0', context: 'array' } - ] + { id: 'data', typeid: 'autodesk.test:test.string-1.0.0', context: 'array' }, + ], }; var OurArrayTestTemplate = { typeid: 'autodesk.tests:ArrayTestID-1.0.0', properties: [ - { id: 'MyArray', typeid: 'Float32', context: 'array' } - ] + { id: 'MyArray', typeid: 'Float32', context: 'array' }, + ], }; var NestedArrayTestTemplate = { @@ -113,10 +112,10 @@ var NestedArrayTestTemplate = { properties: [ { id: 'nest', properties: [ - { id: 'MyArray', typeid: 'Float32', context: 'array' } - ] - } - ] + { id: 'MyArray', typeid: 'Float32', context: 'array' }, + ], + }, + ], }; var ComplexTemplate = { @@ -124,48 +123,47 @@ var ComplexTemplate = { properties: [ { id: 'nest', properties: [ - { id: 'data', typeid: 'Float32' } - ] - } - ] + { id: 'data', typeid: 'Float32' }, + ], + }, + ], }; var ComplexTemplate2 = { typeid: 'autodesk.tests:ComplexProp2-1.0.0', properties: [ { id: 'nest', properties: [ - { id: 'data2', typeid: 'Float32' } - ] - } - ] + { id: 'data2', typeid: 'Float32' }, + ], + }, + ], }; var ComplexTemplate3 = { typeid: 'autodesk.tests:ComplexProp3-1.0.0', properties: [ { id: 'complex1', typeid: 'autodesk.tests:ComplexProp-1.0.0' }, - { id: 'complex2', typeid: 'autodesk.tests:ComplexProp2-1.0.0' } - ] + { id: 'complex2', typeid: 'autodesk.tests:ComplexProp2-1.0.0' }, + ], }; var ComplexArrayTemplate = { typeid: 'autodesk.tests:ComplexArray-1.0.0', properties: [ - { id: 'myarray', typeid: 'autodesk.tests:ComplexProp-1.0.0', context: 'array' } - ] + { id: 'myarray', typeid: 'autodesk.tests:ComplexProp-1.0.0', context: 'array' }, + ], }; var Complex3ArrayTemplate = { typeid: 'autodesk.tests:Complex3Array-1.0.0', properties: [ - { id: 'myarray', typeid: 'autodesk.tests:ComplexProp3-1.0.0', context: 'array' } - ] + { id: 'myarray', typeid: 'autodesk.tests:ComplexProp3-1.0.0', context: 'array' }, + ], }; -describe('ArrayProperty', function () { +describe('ArrayProperty', function() { /** * Get all the objects we need in this test here. */ - before(function () { - + before(function() { PropertyFactory._reregister(OurArrayTestTemplate); PropertyFactory._reregister(TestArrayFloat32); PropertyFactory._reregister(TestString); @@ -182,9 +180,9 @@ describe('ArrayProperty', function () { PropertyFactory._reregister(Complex3ArrayTemplate); }); - describe('API methods - non primitive arrays', function () { + describe('API methods - non primitive arrays', function() { var myProp, stringProp1, stringProp2, stringProp3, stringProp4, myArray; - before(function () { + before(function() { myProp = PropertyFactory.create('autodesk.test:test.nonPrimitiveArray-1.0.0'); stringProp1 = PropertyFactory.create('autodesk.test:test.string-1.0.0'); stringProp2 = PropertyFactory.create('autodesk.test:test.string-1.0.0'); @@ -193,7 +191,7 @@ describe('ArrayProperty', function () { myArray = myProp.get('data'); }); - it('.clear should remove all items from an array and return nothing', function () { + it('.clear should remove all items from an array and return nothing', function() { myArray.push(stringProp1); myArray.push(stringProp2); expect(myArray.length).to.equal(2); @@ -201,19 +199,19 @@ describe('ArrayProperty', function () { expect(myArray.length).to.equal(0); }); - it('.clear should work on an empty array', function () { - expect(function () { myArray.clear(); }).to.not.throw(); - expect(function () { myArray.clear(); }).to.not.throw(); + it('.clear should work on an empty array', function() { + expect(function() { myArray.clear(); }).to.not.throw(); + expect(function() { myArray.clear(); }).to.not.throw(); }); - it('.get should return a property', function () { + it('.get should return a property', function() { myArray.push(stringProp1); var result = myArray.get(0) instanceof BaseProperty; expect(result).to.be.true; expect(myArray.get(0)).to.deep.equal(stringProp1); }); - it('.get should return a target deferenced by a chain of reference properties', function () { + it('.get should return a target deferenced by a chain of reference properties', function() { let root = PropertyFactory.create('NodeProperty'); let reference = PropertyFactory.create('Reference'); let reference2 = PropertyFactory.create('Reference'); @@ -239,8 +237,7 @@ describe('ArrayProperty', function () { root.clear(); }); - - it('.get should return a target deferenced by a chain of reference properties with *', function () { + it('.get should return a target deferenced by a chain of reference properties with *', function() { let root = PropertyFactory.create('NodeProperty'); let reference = PropertyFactory.create('Reference'); let reference2 = PropertyFactory.create('Reference'); @@ -266,15 +263,14 @@ describe('ArrayProperty', function () { root.clear(); }); - it('.get should work with an array to return nested values', function () { + it('.get should work with an array to return nested values', function() { var myComplexArray = PropertyFactory.create('autodesk.tests:ComplexArray-1.0.0')._properties.myarray; var myComplexProp = PropertyFactory.create('autodesk.tests:ComplexProp-1.0.0'); myComplexArray.push(myComplexProp); expect(myComplexArray.get([0, 'nest'])).to.deep.equal(myComplexArray.get(0).get('nest')); }); - - it('.get should work with an array as input', function () { + it('.get should work with an array as input', function() { var testProperty1 = PropertyFactory.create('autodesk.tests:ComplexProp-1.0.0'); testProperty1.get('nest').get('data').setValue(1); var testProperty2 = PropertyFactory.create('autodesk.tests:ComplexProp-1.0.0'); @@ -284,7 +280,7 @@ describe('ArrayProperty', function () { myArray1.push(testProperty2); expect(myArray1.get([0, 'nest', 'data']).getValue()).to.equal(1); }); - it('.get should accept raise level tokens', function () { + it('.get should accept raise level tokens', function() { var testProperty1 = PropertyFactory.create('autodesk.tests:ComplexProp-1.0.0'); testProperty1.get('nest').get('data').setValue(7); var testProperty2 = PropertyFactory.create('autodesk.tests:ComplexProp-1.0.0'); @@ -296,7 +292,7 @@ describe('ArrayProperty', function () { PATH_TOKENS.UP, PATH_TOKENS.UP, 1, 'nest', 'data']) .getValue()).to.equal(8); }); - it('.get should accept path root tokens', function () { + it('.get should accept path root tokens', function() { var testProperty1 = PropertyFactory.create('autodesk.tests:ComplexProp-1.0.0'); testProperty1.get('nest').get('data').setValue(3); var testProperty2 = PropertyFactory.create('autodesk.tests:ComplexProp-1.0.0'); @@ -310,40 +306,40 @@ describe('ArrayProperty', function () { expect(myArray1.get([PATH_TOKENS.ROOT, 'myarray', 2])).to.equal(testProperty3); }); - it('.getEntriesReadOnly should return an array', function () { + it('.getEntriesReadOnly should return an array', function() { myArray.push(stringProp1); myArray.push(stringProp2); expect(myArray.getEntriesReadOnly()).to.deep.equal([stringProp1, stringProp2]); }); - it('.getFullTypeid will return a string of the full type id with or without collection', function () { + it('.getFullTypeid will return a string of the full type id with or without collection', function() { // defaults to false expect(myArray.getFullTypeid()).to.equal('array'); // in_hideCollection: true expect(myArray.getFullTypeid(true)).to.equal('autodesk.test:test.string-1.0.0'); }); - it('.getIds should return an array of string indexes', function () { + it('.getIds should return an array of string indexes', function() { myArray.push(stringProp1); myArray.push(stringProp2); expect(myArray.getIds()).to.deep.equal(['0', '1']); }); - it('.getLength should return the length of the array', function () { + it('.getLength should return the length of the array', function() { expect(myArray.getLength()).to.equal(0); myArray.push(stringProp1); myArray.push(stringProp2); expect(myArray.getLength()).to.equal(2); }); - it('.has should work', function () { + it('.has should work', function() { myArray.push(stringProp1); myArray.push(stringProp2); expect(myArray.has(1)).to.be.true; expect(myArray.has(2)).to.be.false; }); - it('.getRelativePath should return a valid path', function () { + it('.getRelativePath should return a valid path', function() { var testProperty1 = PropertyFactory.create('autodesk.tests:ComplexProp-1.0.0'); var testProperty2 = PropertyFactory.create('autodesk.tests:ComplexProp-1.0.0'); var myArray1 = PropertyFactory.create('autodesk.tests:ComplexArray-1.0.0')._properties.myarray; @@ -355,26 +351,26 @@ describe('ArrayProperty', function () { .to.equal('../../../[0].nest'); }); - it('.getValues should return an array of objects', function () { + it('.getValues should return an array of objects', function() { myArray.push(stringProp1); myArray.push(stringProp2); myArray.setValues({ 0: { - data: 'newTest' - } + data: 'newTest', + }, }); expect(myArray.getValues()).to.deep.equal([ { - data: 'newTest' + data: 'newTest', }, { - data: '' - } + data: '', + }, ]); }); - it('.insert should insert a new property in a non primitive array', function () { + it('.insert should insert a new property in a non primitive array', function() { myArray.insert(0, stringProp1); expect(myArray.getLength()).to.equal(1); expect(myArray.get(0)).to.deep.equal(stringProp1); @@ -382,25 +378,25 @@ describe('ArrayProperty', function () { expect(myArray.getLength()).to.equal(2); }); - it('.insert should push existing values to the right if index already has a property', function () { + it('.insert should push existing values to the right if index already has a property', function() { myArray.insert(0, stringProp1); myArray.insert(0, stringProp2); expect(myArray.getEntriesReadOnly()).to.deep.equal([stringProp2, stringProp1]); }); - it('.insertRange should insert new properties', function () { + it('.insertRange should insert new properties', function() { myArray.insertRange(0, [stringProp1, stringProp2]); expect(myArray.getLength()).to.equal(2); expect(myArray.get(1)).to.deep.equal(stringProp2); }); - it('.insertRange should push existing values to the right if index already has a property', function () { + it('.insertRange should push existing values to the right if index already has a property', function() { myArray.insert(0, stringProp1); myArray.insertRange(0, [stringProp2, stringProp3]); expect(myArray.getEntriesReadOnly()).to.deep.equal([stringProp2, stringProp3, stringProp1]); }); - it('pop should remove only last element of an array and return the removed element', function () { + it('pop should remove only last element of an array and return the removed element', function() { var myDynamicArray = PropertyFactory.create('autodesk.test:test.nonPrimitiveArray-1.0.0')._properties.data; expect(myDynamicArray.length).to.equal(0); var firstString = PropertyFactory.create('autodesk.test:test.string-1.0.0'); @@ -418,11 +414,10 @@ describe('ArrayProperty', function () { expect(myDynamicArray.length).to.equal(2); expect(myDynamicArray.get(0)).to.equal(firstString); expect(myDynamicArray.get(1)).to.equal(secondString); - expect(function () { + expect(function() { myDynamicArray.get(2); }).to.throw(Error); - myDynamicArray.push(thirdString); expect(myDynamicArray.pop()).to.deep.equal(thirdString); myDynamicArray.push(fourthString); @@ -432,11 +427,11 @@ describe('ArrayProperty', function () { myDynamicArray.pop(); myDynamicArray.pop(); expect(myDynamicArray.length).to.equal(0); - expect(function () { myDynamicArray.get(1); }).to.throw(Error); + expect(function() { myDynamicArray.get(1); }).to.throw(Error); expect(myDynamicArray.pop()).to.equal(undefined); }); - it('push should add the element to the last position and return the new length of the array', function () { + it('push should add the element to the last position and return the new length of the array', function() { var myDynamicArray = PropertyFactory.create('autodesk.test:test.nonPrimitiveArray-1.0.0')._properties.data; expect(myDynamicArray.length).to.equal(0); var firstString = PropertyFactory.create('autodesk.test:test.string-1.0.0'); @@ -446,12 +441,12 @@ describe('ArrayProperty', function () { expect(myDynamicArray.length).to.equal(2); expect(myDynamicArray.get(0)).to.equal(firstString); expect(myDynamicArray.get(1)).to.equal(secondString); - expect(function () { + expect(function() { myDynamicArray.get(2); }).to.throw(Error); }); - it('.remove should remove an element from an array, moving remaining elements to the left', function () { + it('.remove should remove an element from an array, moving remaining elements to the left', function() { myArray.push(stringProp1); myArray.push(stringProp2); myArray.remove(1); @@ -462,7 +457,7 @@ describe('ArrayProperty', function () { }); it('.removeRange should remove a range of elements from an array and move the remaining elements to the left', - function () { + function() { myArray.push(stringProp1); myArray.push(stringProp2); myArray.push(stringProp3); @@ -471,7 +466,7 @@ describe('ArrayProperty', function () { expect(myArray.getEntriesReadOnly()).to.deep.equal([stringProp3]); }); - it('.remove and .removeRange should return the items deleted', function () { + it('.remove and .removeRange should return the items deleted', function() { myArray.push(stringProp1); myArray.push(stringProp2); myArray.push(stringProp3); @@ -479,53 +474,53 @@ describe('ArrayProperty', function () { expect(myArray.removeRange(0, 2)).to.deep.equal([stringProp2, stringProp3]); }); - it('.set changes an existing element', function () { + it('.set changes an existing element', function() { myArray.insertRange(0, [stringProp1, stringProp2]); myArray.set(1, stringProp3); expect(myArray.getEntriesReadOnly()).to.deep.equal([stringProp1, stringProp3]); }); - it('.setRange changes a range of existing elements', function () { + it('.setRange changes a range of existing elements', function() { myArray.insertRange(0, [stringProp1, stringProp2]); myArray.setRange(0, [stringProp3, stringProp4]); expect(myArray.getEntriesReadOnly()).to.deep.equal([stringProp3, stringProp4]); }); - it('.set and .setRange should throw if trying to set a non-existing element', function () { + it('.set and .setRange should throw if trying to set a non-existing element', function() { myArray.insertRange(0, [stringProp1, stringProp2]); - var incorrectFn1 = function () { + var incorrectFn1 = function() { myArray.set(3, stringProp3); }; expect(incorrectFn1).to.throw(MSG.SET_OUT_OF_BOUNDS); }); - it('.setRange should throw if the offset is not an integer', function () { + it('.setRange should throw if the offset is not an integer', function() { myArray.insertRange(0, [stringProp1, stringProp2]); expect(() => { myArray.setRange('test', [stringProp3, stringProp4]); }).to.throw(MSG.NOT_NUMBER); }); - it('.setRange should throw if the in_array argument is not an array', function () { + it('.setRange should throw if the in_array argument is not an array', function() { myArray.insertRange(0, [stringProp1, stringProp2]); expect(() => { myArray.setRange(1, stringProp3); }).to.throw(MSG.IN_ARRAY_NOT_ARRAY + 'ArrayProperty.setRange'); }); - it('.set should throw if the offset is not an integer', function () { + it('.set should throw if the offset is not an integer', function() { myArray.insertRange(0, [stringProp1, stringProp2]); expect(() => { myArray.set('test', stringProp3); }).to.throw(MSG.NOT_NUMBER); }); - it('.set should throw if the in_value is an array', function () { + it('.set should throw if the in_value is an array', function() { myArray.insertRange(0, [stringProp1, stringProp2]); expect(() => { myArray.set(0, [stringProp3, stringProp4]); }).to.throw(MSG.ARRAY_SET_ONE_ELEMENT); }); - it('.setValues should work for custom type arrays', function () { + it('.setValues should work for custom type arrays', function() { myArray.push(stringProp1); myArray.push(stringProp2); myArray.setValues({ 0: { - data: 'newTest' - } + data: 'newTest', + }, }); expect(myArray.getValues()).to.deep.equal([{ data: 'newTest' }, { data: '' }]); @@ -535,7 +530,7 @@ describe('ArrayProperty', function () { expect(myArray.getValues()).to.deep.equal([{ data: 'newNewTest' }]); }); - it('.setValues should work to overwrite the whole array', function () { + it('.setValues should work to overwrite the whole array', function() { myArray.push(stringProp1); myArray.push(stringProp2); stringProp3._properties.data.setValue('testing 123'); @@ -544,14 +539,14 @@ describe('ArrayProperty', function () { expect(myArray.length).to.equal(1); }); - it('.setValues should work to overwrite part of the array', function () { + it('.setValues should work to overwrite part of the array', function() { myArray.push(stringProp1); myArray.push(stringProp2); myArray.setValues({ 0: { data: 'test test test' } }); expect(myArray.getValues()).to.deep.equal([{ data: 'test test test' }, { data: '' }]); }); - it('.shift should remove the first element of an array and return the removed element', function () { + it('.shift should remove the first element of an array and return the removed element', function() { myArray.push(stringProp1); myArray.push(stringProp2); myArray.shift(); @@ -560,12 +555,12 @@ describe('ArrayProperty', function () { expect(myArray.length).to.equal(0); }); - it('.shift should return undefined if called on an empty array', function () { + it('.shift should return undefined if called on an empty array', function() { expect(myArray.shift()).to.be.undefined; }); it('.unshift should add a property at the beginnig of an array and return the new length of the array', - function () { + function() { myArray.push(stringProp1); myArray.push(stringProp2); myArray.unshift(stringProp3); @@ -573,31 +568,31 @@ describe('ArrayProperty', function () { expect(myArray.unshift(stringProp4)).to.equal(4); }); - afterEach(function () { + afterEach(function() { myArray.clear(); }); }); - describe('API methods - primitive arrays', function () { + describe('API methods - primitive arrays', function() { var myPrimitiveArray; - before(function () { + before(function() { myPrimitiveArray = PropertyFactory.create('autodesk.test:test.dynamicArray-1.0.0')._properties.data; }); - it('.clear should remove all elements in the array', function () { + it('.clear should remove all elements in the array', function() { myPrimitiveArray.insertRange(0, [1, 2, 3]); expect(myPrimitiveArray.length).to.equal(3); myPrimitiveArray.clear(); expect(myPrimitiveArray.length).to.equal(0); }); - it('.get should return a value', function () { + it('.get should return a value', function() { myPrimitiveArray.insertRange(0, [1, 2, 3]); var result = myPrimitiveArray.get(0); expect(result).to.equal(1); }); - it('.getEntriesReadOnly should return an array', function () { + it('.getEntriesReadOnly should return an array', function() { myPrimitiveArray.insertRange(0, [1, 2, 3]); const result = myPrimitiveArray.getEntriesReadOnly(); assert.equal(result.length, 3); @@ -606,29 +601,29 @@ describe('ArrayProperty', function () { assert.equal(result[2], 3); }); - it('getFullTypeid should return a string of the typeid with or without collection', function () { + it('getFullTypeid should return a string of the typeid with or without collection', function() { expect(myPrimitiveArray.getFullTypeid()).to.equal('array'); expect(myPrimitiveArray.getFullTypeid(true)).to.equal('Int32'); }); - it('.getIds should return an array of index strings', function () { + it('.getIds should return an array of index strings', function() { myPrimitiveArray.insertRange(0, [1, 2, 3]); expect(myPrimitiveArray.getIds()).to.deep.equal(['0', '1', '2']); }); - it('.getLength should return the length of the array', function () { + it('.getLength should return the length of the array', function() { expect(myPrimitiveArray.getLength()).to.equal(0); myPrimitiveArray.insertRange(0, [1, 2, 3]); expect(myPrimitiveArray.getLength()).to.equal(3); }); - it('.has should work', function () { + it('.has should work', function() { myPrimitiveArray.insertRange(0, [1, 2, 3]); expect(myPrimitiveArray.has(1)).to.be.true; expect(myPrimitiveArray.has(4)).to.be.false; }); - it('.setValues and .getValues should work for primitive arrays', function () { + it('.setValues and .getValues should work for primitive arrays', function() { // tests for getValues on typed arrays fail but only on PhantomJS. if (isBrowser && window.top.callPhantom) { this.skip(); @@ -637,31 +632,31 @@ describe('ArrayProperty', function () { MyArrayProp.insertRange(0, [1, 2, 3]); MyArrayProp.setValues({ 0: 12, - 2: 9 + 2: 9, }); expect(MyArrayProp.getValues()).to.deep.equal([12, 2, 9]); MyArrayProp.setValues([3, 4]); expect(MyArrayProp.get(0)).to.equal(3); - expect(function () { MyArrayProp.get(2); }).to.throw(); + expect(function() { MyArrayProp.get(2); }).to.throw(); }); - it('.insert should insert a value in a primitive array and move other values to the right', function () { + it('.insert should insert a value in a primitive array and move other values to the right', function() { myPrimitiveArray.insert(0, 1); expect(myPrimitiveArray.length).to.equal(1); myPrimitiveArray.insert(0, 2); expect(myPrimitiveArray.getValues()).to.deep.equal([2, 1]); }); - it('.insertRange should insert a range of values and move other values to the right', function () { + it('.insertRange should insert a range of values and move other values to the right', function() { myPrimitiveArray.insertRange(0, [1, 2, 3]); expect(myPrimitiveArray.length).to.equal(3); myPrimitiveArray.insertRange(1, [4, 5]); expect(myPrimitiveArray.getValues()).to.deep.equal([1, 4, 5, 2, 3]); }); - it('.pop should remove the last item of a primitive array and return the removed value', function () { + it('.pop should remove the last item of a primitive array and return the removed value', function() { var myArray = PropertyFactory.create('autodesk.test:test.dynamicArray-1.0.0')._properties.data; myArray.push(1); myArray.push(2); @@ -673,35 +668,35 @@ describe('ArrayProperty', function () { expect(myArray.pop()).to.equal(2); }); - it('.pop should return undefined if called on an empty array', function () { + it('.pop should return undefined if called on an empty array', function() { expect(myPrimitiveArray.pop()).to.be.undefined; }); - it('.push should add a value at the end of the array and return the new length', function () { + it('.push should add a value at the end of the array and return the new length', function() { myPrimitiveArray.push(1); myPrimitiveArray.push(2); expect(myPrimitiveArray.getValues()).to.deep.equal([1, 2]); expect(myPrimitiveArray.push(4)).to.equal(3); }); - it('.remove should remove an element from the array and return that element', function () { + it('.remove should remove an element from the array and return that element', function() { myPrimitiveArray.insertRange(0, [1, 2, 3]); expect(myPrimitiveArray.remove(0)).to.equal(1); expect(myPrimitiveArray.getValues()).to.deep.equal([2, 3]); }); - it('.removeRange should remove a range of elements from an array and return those elements', function () { + it('.removeRange should remove a range of elements from an array and return those elements', function() { myPrimitiveArray.insertRange(0, [1, 2, 3, 4, 5]); expect(myPrimitiveArray.removeRange(2, 2)).to.deep.equal([3, 4]); expect(myPrimitiveArray.getValues()).to.deep.equal([1, 2, 5]); }); - it('.resolvePath should work on primitive arrays', function () { + it('.resolvePath should work on primitive arrays', function() { myPrimitiveArray.insertRange(0, [1, 2, 3]); expect(myPrimitiveArray.resolvePath('1')).to.equal(2); }); - it('.set should replace a value in a primitive array', function () { + it('.set should replace a value in a primitive array', function() { var myArray = PropertyFactory.create('autodesk.test:test.dynamicArray-1.0.0')._properties.data; myArray.push(1); myArray.push(2); @@ -711,7 +706,7 @@ describe('ArrayProperty', function () { expect(myArray.getValues()).to.deep.equal([1, 2, 8]); }); - it('.setRange should replace values in a primitive array', function () { + it('.setRange should replace values in a primitive array', function() { var myArray = PropertyFactory.create('autodesk.test:test.dynamicArray-1.0.0')._properties.data; myArray.push(1); myArray.push(2); @@ -722,69 +717,69 @@ describe('ArrayProperty', function () { expect(myArray.getValues()).to.deep.equal([1, 4, 5]); }); - it('.setRange should replace last value in a primitive array', function () { + it('.setRange should replace last value in a primitive array', function() { var myArray = PropertyFactory.create('autodesk.test:test.dynamicArray-1.0.0')._properties.data; myArray.insertRange(0, [1, 2, 3, 4, 5]); myArray.setRange(0, [1, 2, 3, 10, 11]); expect(myArray.getValues()).to.deep.equal([1, 2, 3, 10, 11]); }); - it('.setValues should work to overwrite a whole array', function () { + it('.setValues should work to overwrite a whole array', function() { arrayProp = PropertyFactory.create('autodesk.test:test.dynamicArray-1.0.0')._properties.data; arrayProp.insertRange(0, [1, 2, 3]); expect(arrayProp.get(2)).to.equal(3); arrayProp.setValues([13, 14]); expect(arrayProp.get(0)).to.equal(13); - var incorrectFn = function () { + var incorrectFn = function() { arrayProp.get(2); }; expect(incorrectFn).to.throw(); }); - it('setValues should work to overwrite part of the array', function () { + it('setValues should work to overwrite part of the array', function() { var myArrayProp = PropertyFactory.create('autodesk.test:test.dynamicArray-1.0.0')._properties.data; myArrayProp.insertRange(0, [1, 2, 3]); expect(myArrayProp.get(2)).to.equal(3); myArrayProp.setValues({ 0: 11, - 1: 12 + 1: 12, }); expect(myArrayProp.get(0)).to.equal(11); - var correctFn = function () { + var correctFn = function() { myArrayProp.get(2); }; expect(correctFn).to.not.throw(); expect(myArrayProp.get(2)).to.equal(3); }); - it('.shift should remove the first element of the array and return that element', function () { + it('.shift should remove the first element of the array and return that element', function() { myPrimitiveArray.insertRange(0, [1, 2, 3, 4]); expect(myPrimitiveArray.shift()).to.equal(1); expect(myPrimitiveArray.getValues()).to.deep.equal([2, 3, 4]); }); - it('.unshift should add a value to the beginning of the array and return the new length', function () { + it('.unshift should add a value to the beginning of the array and return the new length', function() { myPrimitiveArray.insertRange(0, [1, 2, 3, 4]); myPrimitiveArray.unshift(5); expect(myPrimitiveArray.unshift(13)).to.equal(6); expect(myPrimitiveArray.getValues()).to.deep.equal([13, 5, 1, 2, 3, 4]); }); - afterEach(function () { + afterEach(function() { myPrimitiveArray.clear(); }); }); - describe('testing specific types of arrays', function () { - it('should support boolean arrays', function () { + describe('testing specific types of arrays', function() { + it('should support boolean arrays', function() { var myBoolArray = PropertyFactory.create('autodesk.test:test.arraybool-1.0.0')._properties.data; expect(myBoolArray.length).to.equal(3); expect(myBoolArray.get(0)).to.equal(false); expect(myBoolArray.get(1)).to.equal(false); expect(myBoolArray.get(2)).to.equal(false); - expect(function () { myBoolArray.get(3); }).to.throw(Error); + expect(function() { myBoolArray.get(3); }).to.throw(Error); myBoolArray.push(true); myBoolArray.push(0); @@ -800,28 +795,28 @@ describe('ArrayProperty', function () { expect(myBoolArray.get(0)).to.equal(true); }); - it('.set and .get should convert float index to int', function () { + it('.set and .get should convert float index to int', function() { var myArray = PropertyFactory.create('String', 'array', ['item 0', 'item 1', 'item 2']); myArray.set(1.2, 'item 1.2'); expect(myArray.getLength()).to.equal(3); expect(myArray.get(1.6)).to.equal('item 1.2'); }); - it('.set and .get should convert string index to int', function () { + it('.set and .get should convert string index to int', function() { var myArray = PropertyFactory.create('String', 'array', ['item 0', 'item 1', 'item 2']); myArray.set('0.3', 'item 0.3'); expect(myArray.getLength()).to.equal(3); expect(myArray.get('0.6')).to.equal('item 0.3'); }); - it('.set and .get should reject float index that cannot be converted to int', function () { + it('.set and .get should reject float index that cannot be converted to int', function() { var myArray = PropertyFactory.create('String', 'array', ['item 0', 'item 1', 'item 2']); expect(() => myArray.set(Infinity, 'item infinity')).to.throw(MSG.NOT_NUMBER + 'in_offset, method: ArrayProperty.setRange or .set'); expect(() => myArray.get(NaN)).to.throw(MSG.IN_POSITION_MUST_BE_NUMBER); }); - it('.set and .get should reject string index that can not be converted to int', function () { + it('.set and .get should reject string index that can not be converted to int', function() { var myArray = PropertyFactory.create('String', 'array', ['item 0', 'item 1', 'item 2']); expect(() => myArray.set('2abc', 'item 2abc')).to.throw(MSG.NOT_NUMBER + 'in_offset, method: ArrayProperty.setRange or .set'); @@ -829,38 +824,37 @@ describe('ArrayProperty', function () { }); }); - describe('Checking the generalized squash function of ArrayProperty', function () { - it('should be squashed to the expected changeset', function (done) { + describe('Checking the generalized squash function of ArrayProperty', function() { + it('should be squashed to the expected changeset', function(done) { var error; try { arrayProp = PropertyFactory.create('autodesk.tests:ArrayTestID-1.0.0')._properties.MyArray; arrayProp.applyChangeSet({ - 'insert': [[0, [0, 0]]] + 'insert': [[0, [0, 0]]], }); arrayProp.cleanDirty(); arrayProp.applyChangeSet({ - 'insert': [[0, [2, 3]]] + 'insert': [[0, [2, 3]]], }); arrayProp.applyChangeSet({ - 'modify': [[1, [9, 44]]] + 'modify': [[1, [9, 44]]], }); arrayProp.applyChangeSet({ - 'insert': [[3, [6, 7, 8]]] + 'insert': [[3, [6, 7, 8]]], }); arrayProp.applyChangeSet({ - 'remove': [[4, 1]] + 'remove': [[4, 1]], }); arrayProp.applyChangeSet({ - 'modify': [[5, [9]]] + 'modify': [[5, [9]]], }); - } catch (e) { error = e; } finally { @@ -868,15 +862,15 @@ describe('ArrayProperty', function () { expect(arrayProp._getDirtyChanges()).to.deep.equal( { 'insert': [[0, [2, 9]], [1, [6, 8]]], - 'modify': [[0, [44, 9]]] - } + 'modify': [[0, [44, 9]]], + }, ); expect(error).to.equal(undefined); done(); } }); - it('Merging of reversible modifications', function () { + it('Merging of reversible modifications', function() { var base = { 'array': { 'value': { @@ -884,15 +878,15 @@ describe('ArrayProperty', function () { [ 0, [ - 2 + 2, ], [ - 1 - ] - ] - ] - } - } + 1, + ], + ], + ], + }, + }, }; var mod = { 'array': { @@ -901,15 +895,15 @@ describe('ArrayProperty', function () { [ 0, [ - 3 + 3, ], [ - 2 - ] - ] - ] - } - } + 2, + ], + ], + ], + }, + }, }; var testChangeSet = new ChangeSet(base); testChangeSet.applyChangeSet(mod); @@ -919,7 +913,7 @@ describe('ArrayProperty', function () { expect(CS['array'].value.modify[0][2][0]).to.equal(1); // Value before modification }); - it('[random numbers test] - the resulting insert should be equal to the data array', function (done) { + it('[random numbers test] - the resulting insert should be equal to the data array', function(done) { var error; this.timeout(120000); // When the code is instrumented for coverage analysis, it takes a lot of time. for (let j = 0; j < 10; j++) { @@ -969,7 +963,6 @@ describe('ArrayProperty', function () { } arrayProp.applyChangeSet(nextChangeset); - var arrayPropTest = PropertyFactory.create('autodesk.tests:ArrayTestID-1.0.0')._properties.MyArray; arrayPropTest.applyChangeSet({ 'insert': [[0, [1, 2, 3, 4, 5, 6, 7, 8, 9]]] }); arrayPropTest.cleanDirty(); @@ -985,9 +978,7 @@ describe('ArrayProperty', function () { testFailed = true; break; } - } - } catch (e) { error = e; } finally { @@ -1000,18 +991,17 @@ describe('ArrayProperty', function () { }); }); - - describe('Fixed Size arrays', function () { + describe('Fixed Size arrays', function() { // Should throw an exception when you create a primitive type and try to add it to an array // that takes values of that primitive type - it('should support fixed size arrays for a primitive type', function () { + it('should support fixed size arrays for a primitive type', function() { var myFloatArray = PropertyFactory.create('autodesk.test:test.arrayfloat32-1.0.0')._properties.data; expect(myFloatArray.length).to.equal(3); expect(myFloatArray.get(0)).to.equal(0); expect(myFloatArray.get(1)).to.equal(0); expect(myFloatArray.get(2)).to.equal(0); - expect(function () { myFloatArray.get(3); }).to.throw(Error); + expect(function() { myFloatArray.get(3); }).to.throw(Error); // Array should be clean after creation and but full serialization should return an insert expect(myFloatArray._serialize(true)).to.be.empty; // Waiting for fix from OT @@ -1022,14 +1012,14 @@ describe('ArrayProperty', function () { // expect(function() { myFloatArray.removeRange(0,1);}).to.throw(Error); }); - it('should support fixed size arrays for a primitive type', function () { + it('should support fixed size arrays for a primitive type', function() { var myStringArray = PropertyFactory.create('autodesk.test:test.arraystring-1.0.0')._properties.data; expect(myStringArray.length).to.equal(3); expect(myStringArray.get(0)).to.equal(''); expect(myStringArray.get(1)).to.equal(''); expect(myStringArray.get(2)).to.equal(''); - expect(function () { myStringArray.get(3); }).to.throw(Error); + expect(function() { myStringArray.get(3); }).to.throw(Error); // Array should be clean after creation and but full serialization should return an insert expect(myStringArray._serialize(true)).to.be.empty; @@ -1040,15 +1030,14 @@ describe('ArrayProperty', function () { // expect(function() { myFloatArray.removeRange(0,1);}).to.throw(Error); }); - - it('should support fixed size arrays for a complex type', function () { + it('should support fixed size arrays for a complex type', function() { var myCustomArray = PropertyFactory.create('autodesk.test:test.customarray-1.0.0')._properties.data; expect(myCustomArray.length).to.equal(3); expect(myCustomArray.get(0)).to.be.instanceof(BaseProperty); expect(myCustomArray.get(1)).to.be.instanceof(BaseProperty); expect(myCustomArray.get(2)).to.be.instanceof(BaseProperty); - expect(function () { myCustomArray.get(3); }).to.throw(Error); + expect(function() { myCustomArray.get(3); }).to.throw(Error); // Array should be clean after creation and but full serialization should return an insert expect(myCustomArray._serialize(true)).to.be.empty; @@ -1062,8 +1051,8 @@ describe('ArrayProperty', function () { }); }); - describe('Checking normalized changeset ability of ArrayProperty', function () { - it('should be equal to the expected value', function (done) { + describe('Checking normalized changeset ability of ArrayProperty', function() { + it('should be equal to the expected value', function(done) { var error; try { arrayProp = PropertyFactory.create('autodesk.tests:ArrayTestID-1.0.0')._properties.MyArray; @@ -1075,22 +1064,21 @@ describe('ArrayProperty', function () { arrayProp.applyChangeSet({ 'modify': [[3, [33]]] }); arrayProp.applyChangeSet({ 'remove': [[0, 2]] }); arrayProp.applyChangeSet({ 'insert': [[0, [123, 456]]] }); - } catch (e) { error = e; } finally { expect(arrayProp).to.not.equal(null); expect(arrayProp._getDirtyChanges()).to.deep.equal( { - 'insert': [[0, [123, 456, 333, 33, 6, 7, 8, 9, 0]]] - } + 'insert': [[0, [123, 456, 333, 33, 6, 7, 8, 9, 0]]], + }, ); expect(error).to.equal(undefined); done(); } }); - it('[random numbers test] - the resulting insert should be equal to the data array', function (done) { + it('[random numbers test] - the resulting insert should be equal to the data array', function(done) { var error; try { arrayProp = PropertyFactory.create('autodesk.tests:ArrayTestID-1.0.0')._properties.MyArray; @@ -1136,7 +1124,6 @@ describe('ArrayProperty', function () { } arrayProp.applyChangeSet(nextChangeset); } - } catch (e) { error = e; } finally { @@ -1153,8 +1140,8 @@ describe('ArrayProperty', function () { }); }); - describe('Checking deserialization', function () { - var runDeserializationTests = function (testArrayOperation, testArray, primitiveProperty) { + describe('Checking deserialization', function() { + var runDeserializationTests = function(testArrayOperation, testArray, primitiveProperty) { // Serialization into an empty array var values = ['test1', 'test2']; testArrayOperation(values, { insert: [[0, values]] }); @@ -1194,46 +1181,46 @@ describe('ArrayProperty', function () { testArrayOperation(values, {}); }; - it('of a primitive array property', function () { + it('of a primitive array property', function() { var stringArray = PropertyFactory.create('String', 'array'); - var testArrayOperation = function (values, expectedChangeSet) { + var testArrayOperation = function(values, expectedChangeSet) { stringArray.deserialize(values.length !== 0 ? { insert: [[0, values]] } : {}); expect(stringArray.getEntriesReadOnly()).to.deep.equal(values); expect(stringArray.serialize({ dirtyOnly: true, - dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE + dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE, })).to.deep.equal(expectedChangeSet); expect(stringArray.serialize({ dirtyOnly: true, - dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.DIRTY_CHANGE + dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.DIRTY_CHANGE, })).to.deep.equal(expectedChangeSet); }; runDeserializationTests(testArrayOperation, stringArray, true); }); - it('of a custom type array', function () { + it('of a custom type array', function() { var testArray = PropertyFactory.create('autodesk.test:test.string-1.0.0', 'array'); - var mapStringsToCustomType = function (strings) { - return strings.map(function (x) { + var mapStringsToCustomType = function(strings) { + return strings.map(function(x) { return { String: { - data: x + data: x, }, - typeid: 'autodesk.test:test.string-1.0.0' + typeid: 'autodesk.test:test.string-1.0.0', }; }); }; - var testArrayOperation = function (values, expectedChangeSet) { + var testArrayOperation = function(values, expectedChangeSet) { testArray.deserialize(values.length !== 0 ? { insert: [[0, - mapStringsToCustomType(values) - ]] + mapStringsToCustomType(values), + ]], } : {}); - expect(testArray.getEntriesReadOnly().map(function (x) { + expect(testArray.getEntriesReadOnly().map(function(x) { return x.get('data').getValue(); })).to.deep.equal(values); @@ -1243,11 +1230,11 @@ describe('ArrayProperty', function () { expect(testArray.serialize({ dirtyOnly: true, - dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE + dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE, })).to.deep.equal(expectedChangeSet); expect(testArray.serialize({ dirtyOnly: true, - dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.DIRTY_CHANGE + dirtinessType: BaseProperty.MODIFIED_STATE_FLAGS.DIRTY_CHANGE, })).to.deep.equal(expectedChangeSet); }; @@ -1255,9 +1242,8 @@ describe('ArrayProperty', function () { }); }); - - describe('Checking rebasing of an ArrayProperty', function () { - it('a remove-modify should be correctly rebased to the given changeset and cause conflicts', function (done) { + describe('Checking rebasing of an ArrayProperty', function() { + it('a remove-modify should be correctly rebased to the given changeset and cause conflicts', function(done) { var error; try { arrayProp = PropertyFactory.create('autodesk.tests:ArrayTestID-1.0.0')._properties.MyArray; @@ -1276,7 +1262,6 @@ describe('ArrayProperty', function () { arrayProp2.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY | BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE); - // apply different operations to the two properties in parallel arrayProp1._properties.MyArray.applyChangeSet({ 'remove': [[2, 1], [4, 1], [6, 1]] }); @@ -1289,7 +1274,6 @@ describe('ArrayProperty', function () { // Perform the actual rebase conflicts = []; changeSet1._rebaseChangeSet(changeSet2, conflicts); - } catch (e) { error = e; } finally { @@ -1303,8 +1287,8 @@ describe('ArrayProperty', function () { conflictingChange: { type: ChangeSet.ConflictType.COLLIDING_SET, - operation: [2, [23]] - } + operation: [2, [23]], + }, }, { path: 'MyArray', @@ -1312,21 +1296,21 @@ describe('ArrayProperty', function () { conflictingChange: { type: ChangeSet.ConflictType.COLLIDING_SET, - operation: [6, [34]] - } - }] + operation: [6, [34]], + }, + }], ); expect(changeSet2['array'].MyArray).to.deep.equal( { - 'modify': [[2, [24, 33, 35]]] - } + 'modify': [[2, [24, 33, 35]]], + }, ); done(); } }); - it('@bugfix ensure existing properties are unparented during deserialization', function () { + it('@bugfix ensure existing properties are unparented during deserialization', function() { // Bug caused by deserialization during rebase arrayProp = PropertyFactory.create(TestDynamicLengthNonPrimitiveArray.typeid); const customProp = PropertyFactory.create('autodesk.test:test.string-1.0.0'); @@ -1344,7 +1328,7 @@ describe('ArrayProperty', function () { expect(customProp.getParent()).to.equal(undefined); }); - it('rebase of independent modifies in array', function () { + it('rebase of independent modifies in array', function() { var arrayObj = PropertyFactory.create('autodesk.tests:Complex3Array-1.0.0'); var arrayProperty = arrayObj.get('myarray'); arrayProperty.insert(0, PropertyFactory.create('autodesk.tests:ComplexProp3-1.0.0')); @@ -1371,9 +1355,8 @@ describe('ArrayProperty', function () { // TODO: add more rebase tests here! }); - describe('Using prettyPrint()', function () { - - it('should output a pretty string with number items', function () { + describe('Using prettyPrint()', function() { + it('should output a pretty string with number items', function() { var property = PropertyFactory.create('autodesk.test:test.arrayfloat32-1.0.0'); property.resolvePath('data').set(0, 4); property.resolvePath('data').set(1, 5); @@ -1386,13 +1369,13 @@ describe('ArrayProperty', function () { ' 2: 6\n' + ' ]\n'; var prettyStr = ''; - property.prettyPrint(function (str) { + property.prettyPrint(function(str) { prettyStr += str + '\n'; }); expect(prettyStr).to.equal(expectedPrettyStr); }); - it('should output a pretty string with string items', function () { + it('should output a pretty string with string items', function() { var property = PropertyFactory.create('autodesk.test:test.arraystring-1.0.0'); var expectedPrettyStr = 'undefined (autodesk.test:test.arraystring-1.0.0):\n' + @@ -1402,13 +1385,13 @@ describe('ArrayProperty', function () { ' 2: ""\n' + ' ]\n'; var prettyStr = ''; - property.prettyPrint(function (str) { + property.prettyPrint(function(str) { prettyStr += str + '\n'; }); expect(prettyStr).to.equal(expectedPrettyStr); }); - it('should output a pretty string with custom items', function () { + it('should output a pretty string with custom items', function() { var property = PropertyFactory.create('autodesk.test:test.customarray-1.0.0'); var expectedPrettyStr = 'undefined (autodesk.test:test.customarray-1.0.0):\n' + @@ -1421,21 +1404,21 @@ describe('ArrayProperty', function () { ' data (String): ""\n' + ' ]\n'; var prettyStr = ''; - property.prettyPrint(function (str) { + property.prettyPrint(function(str) { prettyStr += str + '\n'; }); expect(prettyStr).to.equal(expectedPrettyStr); }); }); - it('should push', function () { + it('should push', function() { var array = PropertyFactory.create('String', 'array', [0, 1, 2]); array.push(3); array.getLength().should.equal(4); array.push([4, 5]); array.getLength().should.equal(6); }); - it('should pop', function () { + it('should pop', function() { var array = PropertyFactory.create('String', 'array', [0, 1, 2]); var element = array.pop(); element.should.equal(2); @@ -1444,7 +1427,7 @@ describe('ArrayProperty', function () { }); // there is no .shiftValue // should replace the value with a property - it.skip('should shift', function () { + it.skip('should shift', function() { var array = PropertyFactory.create('String', 'array', [0, 1, 2]); var element = array.shift(); element.should.equal(0); @@ -1454,7 +1437,7 @@ describe('ArrayProperty', function () { }); // there is no .unshiftValue // should replace the value with a property - it.skip('should unshift', function () { + it.skip('should unshift', function() { var array = PropertyFactory.create('String', 'array', [0, 1, 2]); array.unshift(3); array.getLength().should.equal(4); @@ -1462,14 +1445,14 @@ describe('ArrayProperty', function () { array.getLength().should.equal(6); }); - it('should support boolean arrays', function () { + it('should support boolean arrays', function() { var myBoolArray = PropertyFactory.create('autodesk.test:test.arraybool-1.0.0')._properties.data; expect(myBoolArray.length).to.equal(3); expect(myBoolArray.get(0)).to.equal(false); expect(myBoolArray.get(1)).to.equal(false); expect(myBoolArray.get(2)).to.equal(false); - expect(function () { myBoolArray.get(3); }).to.throw(Error); + expect(function() { myBoolArray.get(3); }).to.throw(Error); myBoolArray.push(true); myBoolArray.push(0); @@ -1485,7 +1468,7 @@ describe('ArrayProperty', function () { expect(myBoolArray.get(0)).to.equal(true); }); - it('.set and .get should convert float index to int', function () { + it('.set and .get should convert float index to int', function() { var myArray = PropertyFactory.create('autodesk.test:test.string-1.0.0', 'array'); var prop0 = PropertyFactory.create('autodesk.test:test.string-1.0.0', 'single', { data: 'item 0' }); var prop1 = PropertyFactory.create('autodesk.test:test.string-1.0.0', 'single', { data: 'item 1' }); @@ -1497,7 +1480,7 @@ describe('ArrayProperty', function () { expect(myArray.get(1.6)).to.equal(prop1_2); }); - it('.set and .get should convert string index to int', function () { + it('.set and .get should convert string index to int', function() { var myArray = PropertyFactory.create('autodesk.test:test.string-1.0.0', 'array'); var prop0 = PropertyFactory.create('autodesk.test:test.string-1.0.0', 'single', { data: 'item 0' }); var prop1 = PropertyFactory.create('autodesk.test:test.string-1.0.0', 'single', { data: 'item 1' }); @@ -1509,7 +1492,7 @@ describe('ArrayProperty', function () { expect(myArray.get('0.6')).to.equal(prop0_3); }); - it('.set and .get should reject float index that cannot be converted to int', function () { + it('.set and .get should reject float index that cannot be converted to int', function() { var myArray = PropertyFactory.create('autodesk.test:test.string-1.0.0', 'array'); var prop0 = PropertyFactory.create('autodesk.test:test.string-1.0.0', 'single', { data: 'item 0' }); var prop1 = PropertyFactory.create('autodesk.test:test.string-1.0.0', 'single', { data: 'item 1' }); @@ -1519,7 +1502,7 @@ describe('ArrayProperty', function () { expect(() => myArray.get(NaN)).to.throw(MSG.IN_POSITION_MUST_BE_NUMBER); }); - it('.setValue and .getValue should reject string index that can not be converted to int', function () { + it('.setValue and .getValue should reject string index that can not be converted to int', function() { var myArray = PropertyFactory.create('autodesk.test:test.string-1.0.0', 'array'); var prop0 = PropertyFactory.create('autodesk.test:test.string-1.0.0', 'single', { data: 'item 0' }); var prop1 = PropertyFactory.create('autodesk.test:test.string-1.0.0', 'single', { data: 'item 1' }); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/baseProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/baseProperty.spec.js index fcacd5f6e1e3..b0d3461cc597 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/baseProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/baseProperty.spec.js @@ -2,7 +2,7 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /** * @fileoverview In this file, we will test the functions of a BaseProperty object * described in /src/properties/baseProperty.js @@ -10,14 +10,14 @@ var PropertyFactory, ChangeSet, MSG, BaseProperty; -describe('BaseProperty', function () { +describe('BaseProperty', function() { /** * Get all the objects we need in this test here. */ - before(function () { + before(function() { PropertyFactory = require('../..').PropertyFactory; - ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet - MSG = require('@fluid-experimental/property-common').constants.MSG + ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet; + MSG = require('@fluid-experimental/property-common').constants.MSG; BaseProperty = require('../..').BaseProperty; var TestPropertyObject = { @@ -30,19 +30,19 @@ describe('BaseProperty', function () { id: 'test[property]', properties: [ { id: '.property.', properties: [ - { id: 'test', typeid: 'String' } - ] - } - ] - } - ] + { id: 'test', typeid: 'String' }, + ], + }, + ], + }, + ], }; PropertyFactory._reregister(TestPropertyObject); }); - describe('Serializing a BaseProperty with special characters', function () { - it('should be possible to serialize a property with special characters', function () { + describe('Serializing a BaseProperty with special characters', function() { + it('should be possible to serialize a property with special characters', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); myProp._properties['test.property'].value = 'a'; myProp._properties['test"property"'].value = 'b'; @@ -58,32 +58,32 @@ describe('BaseProperty', function () { }); }); - describe('Get should work', function () { + describe('Get should work', function() { // Test whether .get accepts the correct parameters - it('should accept an id (string) or an array of ids', function () { + it('should accept an id (string) or an array of ids', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); - var correctArrayFn = function () { + var correctArrayFn = function() { myProp.get(['test']); }; - var correctStringFn = function () { + var correctStringFn = function() { myProp.get('test'); }; expect(correctArrayFn).to.not.throw(); expect(correctStringFn).to.not.throw(); }); // .get(['test1','test2']) === .get('test1').get('test2') - it('when an array is passed, it should do a .get for each id in the array', function () { + it('when an array is passed, it should do a .get for each id in the array', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); expect(myProp.get(['test[property]', '.property.', 'test'])).to.equal( myProp.get('test[property]').get('.property.').get('test')); }); - it('when an array is passed with a bad path, it should return undefined', function () { + it('when an array is passed with a bad path, it should return undefined', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); expect(myProp.get(['wrong path', '.property', 'test'])).to.be.undefined; }); - it('should work with raise level path tokens', function () { + it('should work with raise level path tokens', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); expect(myProp.get(['test[property]', '.property.', BaseProperty.PATH_TOKENS.UP, '.property.', 'test'])).to.deep.equal(myProp.get('test[property]').get('.property.').get('test')); @@ -92,7 +92,7 @@ describe('BaseProperty', function () { 'simple_property'])).to.deep.equal(myProp.get('simple_property')); }); - it('should work with path root tokens', function () { + it('should work with path root tokens', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); expect(myProp.get([BaseProperty.PATH_TOKENS.ROOT])).to.equal(myProp); expect(myProp.get([BaseProperty.PATH_TOKENS.ROOT, 'simple_property'])) @@ -101,40 +101,40 @@ describe('BaseProperty', function () { }); }); - describe('GetValue should work', function () { - it('should return the value of a primitive property', function () { + describe('GetValue should work', function() { + it('should return the value of a primitive property', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); myProp._properties['test.property'].value = 'a'; var myValue = myProp.getValue(['test.property']); expect(myValue).to.equal('a'); }); - it('should work with an array of paths', function () { + it('should work with an array of paths', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); myProp.get(['test[property]', '.property.', 'test']).setValue('b'); expect(myProp.getValue(['test[property]', '.property.', 'test'])).to.equal('b'); }); - it('should throw if using .getValue on a non-primitive property', function () { + it('should throw if using .getValue on a non-primitive property', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); - var incorrectFn = function () { + var incorrectFn = function() { myProp.getValue(['test[property]']); }; expect(incorrectFn).to.throw(); }); }); - describe('GetValues should work', function () { - it('should return the values of a property', function () { + describe('GetValues should work', function() { + it('should return the values of a property', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); myProp.setValues({ 'simple_property': 'string1', 'test"property"': 'string3', 'test[property]': { '.property.': { - 'test': 'string4' - } - } + 'test': 'string4', + }, + }, }); expect(myProp.getValues()).to.deep.equal({ @@ -143,79 +143,78 @@ describe('BaseProperty', function () { 'test"property"': 'string3', 'test[property]': { '.property.': { - 'test': 'string4' - } - } + 'test': 'string4', + }, + }, }); }); - it('setValues should accept the output of getValues as a valid input', function () { + it('setValues should accept the output of getValues as a valid input', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); myProp.setValues({ 'simple_property': 'string1', 'test"property"': 'string3', 'test[property]': { '.property.': { - 'test': 'string4' - } - } + 'test': 'string4', + }, + }, }); - var correctFn = function () { + var correctFn = function() { myProp.setValues(myProp.getValues()); }; expect(correctFn).to.not.throw(); }); }); - describe('setValues should work', function () { - it('should accept an object and set each values in that object', function () { + describe('setValues should work', function() { + it('should accept an object and set each values in that object', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); myProp.setValues({ 'simple_property': 'string1', 'test[property]': { '.property.': { - 'test': 'string2' - } - } + 'test': 'string2', + }, + }, }); expect(myProp.get('simple_property').getValue()).to.equal('string1'); expect(myProp.get(['test[property]', '.property.', 'test']).getValue()).to.equal('string2'); }); - it('should throw if trying to insert in a non-exiting path', function () { + it('should throw if trying to insert in a non-exiting path', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); - var invalidFunction = function () { + var invalidFunction = function() { myProp.setValues({ 'simple_property': 'string1', 'test[property]': { '.property.': { - 'test123': 'string2' - } - } + 'test123': 'string2', + }, + }, }); }; // TODO: move this to constants.js expect(invalidFunction).to.throw(MSG.SET_VALUES_PATH_INVALID + 'test123'); }); - it('should throw if trying to insert into a path that resolves to a property', function () { + it('should throw if trying to insert into a path that resolves to a property', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); - var invalidFunction = function () { + var invalidFunction = function() { myProp.setValues({ 'simple_property': 'string1', 'test[property]': { - '.property.': 'string2' - } + '.property.': 'string2', + }, }); }; expect(invalidFunction).to.throw(MSG.SET_VALUES_PATH_PROPERTY + '.property.'); }); - }); - describe('Path resolution should work', function () { + describe('Path resolution should work', function() { // Test whether the right paths are returned - it('should work with getAbsolutePath', function () { + it('should work with getAbsolutePath', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); expect(myProp.get('simple_property').getAbsolutePath()).to.equal('/simple_property'); @@ -229,7 +228,7 @@ describe('BaseProperty', function () { .get('test').getAbsolutePath()).to.equal('/"test[property]".".property.".test'); }); - it('should work with getRelativePath', function () { + it('should work with getRelativePath', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); var nested = myProp.get('test[property]'); expect(myProp.get(['test[property]', '.property.', 'test']) @@ -240,7 +239,7 @@ describe('BaseProperty', function () { }); // Test that path resolution works - it('should work with resolvePath', function () { + it('should work with resolvePath', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); expect(myProp.resolvePath('simple_property')).to.equal(myProp.get('simple_property')); @@ -259,7 +258,7 @@ describe('BaseProperty', function () { myProp.get('simple_property')); }); - it('should return undefined for invalid paths', function () { + it('should return undefined for invalid paths', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); expect(myProp.resolvePath('invalid_path')).to.be.undefined; @@ -267,8 +266,8 @@ describe('BaseProperty', function () { }); }); - describe('cleanDirty', function () { - it('should work for paths with special characters', function () { + describe('cleanDirty', function() { + it('should work for paths with special characters', function() { var property = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); property.resolvePath('"test[property]".".property.".test').value = 'test'; property.cleanDirty(); @@ -277,25 +276,25 @@ describe('BaseProperty', function () { }); }); - it('should clone the property set', function (done) { + it('should clone the property set', function(done) { var nodeProperty = PropertyFactory.create('NodeProperty'); nodeProperty.deserialize({ insert: { String: { result1: 'foo', - result2: 'bar' + result2: 'bar', }, NodeProperty: { result3: { insert: { Uint32: { - result4: 4 - } - } - } - } - } + result4: 4, + }, + }, + }, + }, + }, }); var clone = nodeProperty.clone(); @@ -305,7 +304,7 @@ describe('BaseProperty', function () { done(); }); - it('should support reapplying dirty flags on non-identical changeSets', function (done) { + it('should support reapplying dirty flags on non-identical changeSets', function(done) { let nodeProperty = PropertyFactory.create('NodeProperty'); nodeProperty.insert('result1', PropertyFactory.create('String')); @@ -313,19 +312,18 @@ describe('BaseProperty', function () { nodeProperty.insert('result3', PropertyFactory.create('Int32')); nodeProperty.insert('result4', PropertyFactory.create('Int32')); - const changeset1 = { String: { result1: 'foo', - result2: 'bar' - } + result2: 'bar', + }, }; const changeset2 = { Int32: { result3: 10, - result4: 11 - } + result4: 11, + }, }; nodeProperty._reapplyDirtyFlags(changeset1, changeset2); @@ -333,12 +331,12 @@ describe('BaseProperty', function () { done(); }); - it('should be able to handle duplicate namespace', function () { + it('should be able to handle duplicate namespace', function() { var ANumber = { typeid: 'autodesk.tests:ANumber-1.0.0', properties: [{ - id: 'aValue', typeid: 'Int32' - }] + id: 'aValue', typeid: 'Int32', + }], }; PropertyFactory.register(ANumber); @@ -347,8 +345,8 @@ describe('BaseProperty', function () { properties: [ { id: 'aValue', typeid: 'autodesk.tests:ANumber-1.0.0' }, { id: 'anotherValue', typeid: 'autodesk.tests:ANumber-1.0.0' }, - { id: 'thirdValue', typeid: 'autodesk.tests:ANumber-1.0.0' } - ] + { id: 'thirdValue', typeid: 'autodesk.tests:ANumber-1.0.0' }, + ], }; PropertyFactory.register(SomeNumbers); @@ -365,12 +363,12 @@ describe('BaseProperty', function () { expect(aValue).to.exist; }); - describe('getContext', function () { - it('should work with context of single', function () { + describe('getContext', function() { + it('should work with context of single', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); expect(myProp.getContext()).to.equal('single'); }); - it('should work with other contexts', function () { + it('should work with other contexts', function() { var arrayProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0', 'array'); expect(arrayProp.getContext()).to.equal('array'); var mapProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0', 'map'); @@ -378,30 +376,30 @@ describe('BaseProperty', function () { }); }); - describe('getFullTypeid', function () { - it('should return the typeid of the property', function () { + describe('getFullTypeid', function() { + it('should return the typeid of the property', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); expect(myProp.getFullTypeid()).to.equal('autodesk.tests:property.with.special.characters-1.0.0'); }); }); - describe('getTypeid', function () { - it('should return the typeid of the property', function () { + describe('getTypeid', function() { + it('should return the typeid of the property', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); expect(myProp.getTypeid()).to.equal('autodesk.tests:property.with.special.characters-1.0.0'); }); }); - describe('getId', function () { - it('should return the id of the property', function () { + describe('getId', function() { + it('should return the id of the property', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); var nested = myProp.get('test.property'); expect(nested.getId()).to.equal('test.property'); }); }); - describe('getParent', function () { - it('should return the parent property', function () { + describe('getParent', function() { + it('should return the parent property', function() { var myProp = PropertyFactory.create('autodesk.tests:property.with.special.characters-1.0.0'); var nested = myProp.get('test.property'); expect(nested.getParent()).to.deep.equal(myProp); @@ -409,10 +407,10 @@ describe('BaseProperty', function () { }); // Other aspects of traverseDown function are already tested. Missing BREAK_TRAVERSAL and paths only. - describe('traverseDown, hasPendingChanges and getPendingChanges', function () { + describe('traverseDown, hasPendingChanges and getPendingChanges', function() { var BREAK_TRAVERSAL; - before(function () { + before(function() { BREAK_TRAVERSAL = require('../..').BaseProperty.BREAK_TRAVERSAL; var TestTraversalObject = { typeid: 'autodesk.tests:property.traversal-1.0.0', @@ -424,43 +422,43 @@ describe('BaseProperty', function () { id: 'p2p1', properties: [ { id: 'p2p1p1', typeid: 'String' }, { id: 'p2p1p2', typeid: 'String' }, - { id: 'p2p1p3', typeid: 'String' } - ] + { id: 'p2p1p3', typeid: 'String' }, + ], }, { id: 'p2p2', properties: [ { id: 'p2p2p1', typeid: 'String' }, { id: 'p2p2p2', typeid: 'String' }, - { id: 'p2p2p3', typeid: 'Int32' } - ] - } - ] + { id: 'p2p2p3', typeid: 'Int32' }, + ], + }, + ], }, { id: 'p3', typeid: 'String' }, { id: 'p4', properties: [ { id: 'p4p1', properties: [ - { id: 'p4p1p1', typeid: 'String' } - ] + { id: 'p4p1p1', typeid: 'String' }, + ], }, { id: 'p4p2', properties: [ - { id: 'p4p2p1', typeid: 'String' } - ] - } - ] - } - ] + { id: 'p4p2p1', typeid: 'String' }, + ], + }, + ], + }, + ], }; PropertyFactory.register(TestTraversalObject); }); - it('should stop when callback returns BREAK_TRAVERSAL', function () { + it('should stop when callback returns BREAK_TRAVERSAL', function() { var property = PropertyFactory.create('autodesk.tests:property.traversal-1.0.0'); var nbrCalls = 0; - var breakTrav = function (prop) { + var breakTrav = function(prop) { if (++nbrCalls === 5) { return BREAK_TRAVERSAL; } @@ -470,9 +468,9 @@ describe('BaseProperty', function () { expect(nbrCalls).to.equal(5); }); - it('should provide path of each prop', function () { + it('should provide path of each prop', function() { var arrPaths = []; - var gatherPaths = function (prop, path) { + var gatherPaths = function(prop, path) { arrPaths.push(path); }; var property = PropertyFactory.create('autodesk.tests:property.traversal-1.0.0'); @@ -480,7 +478,7 @@ describe('BaseProperty', function () { expect(arrPaths).to.deep.equal(['p4p1', 'p4p1.p4p1p1', 'p4p2', 'p4p2.p4p2p1']); }); - it('should return pending changes', function () { + it('should return pending changes', function() { var property = PropertyFactory.create('autodesk.tests:property.traversal-1.0.0'); expect(property.resolvePath('p2').getPendingChanges()).to.deep.equal(new ChangeSet({})); expect(property.resolvePath('p2').hasPendingChanges()).to.be.false; @@ -492,7 +490,7 @@ describe('BaseProperty', function () { expect(property.resolvePath('p2').hasPendingChanges()).to.be.true; }); - it('should output a pretty string with prettyPrint()', function () { + it('should output a pretty string with prettyPrint()', function() { var property = PropertyFactory.create('autodesk.tests:property.traversal-1.0.0'); var expectedPrettyStr = 'p2 (ContainerProperty):\n' + @@ -505,13 +503,13 @@ describe('BaseProperty', function () { ' p2p2p2 (String): ""\n' + ' p2p2p3 (Int32): 0\n'; var prettyStr = ''; - property.resolvePath('p2').prettyPrint(function (str) { + property.resolvePath('p2').prettyPrint(function(str) { prettyStr += str + '\n'; }); expect(prettyStr).to.equal(expectedPrettyStr); }); }); - describe('Ancestry relations should be resolved correctly', function () { + describe('Ancestry relations should be resolved correctly', function() { /** * creates a workspace * @return {property-properties.Workspace} workspace @@ -520,8 +518,8 @@ describe('BaseProperty', function () { return Promise.resolve(PropertyFactory.create('NodeProperty')); } - it('property should be ancestor of subproperty', function () { - return createRootProperty().then(function (workspace) { + it('property should be ancestor of subproperty', function() { + return createRootProperty().then(function(workspace) { var property = PropertyFactory.create('autodesk.tests:property.traversal-1.0.0'); var subproperty = property.resolvePath('p2.p2p1.p2p1p2'); workspace.insert('test', property); @@ -529,22 +527,22 @@ describe('BaseProperty', function () { }); }); - it('property should not be ancestor itself', function () { - return createRootProperty().then(function (workspace) { + it('property should not be ancestor itself', function() { + return createRootProperty().then(function(workspace) { var property = PropertyFactory.create('autodesk.tests:property.traversal-1.0.0'); expect(property.isAncestorOf(property)).to.equal(false); }); }); - it('property not in workspace should correctly resolve ancestry', function () { + it('property not in workspace should correctly resolve ancestry', function() { var property = PropertyFactory.create('autodesk.tests:property.traversal-1.0.0'); var subproperty = property.resolvePath('p2.p2p1.p2p1p2'); expect(property.isAncestorOf(subproperty)).to.equal(true); expect(subproperty.isDescendantOf(property)).to.equal(true); }); - it('property should be ancestor of subproperty', function () { - return createRootProperty().then(function (workspace) { + it('property should be ancestor of subproperty', function() { + return createRootProperty().then(function(workspace) { var property = PropertyFactory.create('autodesk.tests:property.traversal-1.0.0'); var subproperty = property.resolvePath('p2.p2p1.p2p1p2'); workspace.insert('test', property); @@ -552,8 +550,8 @@ describe('BaseProperty', function () { }); }); - it('subproperty should be descendant of property', function () { - return createRootProperty().then(function (workspace) { + it('subproperty should be descendant of property', function() { + return createRootProperty().then(function(workspace) { var property = PropertyFactory.create('autodesk.tests:property.traversal-1.0.0'); var subproperty = property.resolvePath('p2.p2p1.p2p1p2'); workspace.insert('test', property); @@ -561,8 +559,8 @@ describe('BaseProperty', function () { }); }); - it('property in array property should be descendant of array', function () { - return createRootProperty().then(function (workspace) { + it('property in array property should be descendant of array', function() { + return createRootProperty().then(function(workspace) { var property = PropertyFactory.create('autodesk.tests:property.traversal-1.0.0', 'array'); var element = PropertyFactory.create('autodesk.tests:property.traversal-1.0.0'); property.push(element); @@ -572,8 +570,8 @@ describe('BaseProperty', function () { }); }); - it('array property should be ancestor of property in array', function () { - return createRootProperty().then(function (workspace) { + it('array property should be ancestor of property in array', function() { + return createRootProperty().then(function(workspace) { var property = PropertyFactory.create('autodesk.tests:property.traversal-1.0.0', 'array'); var element = PropertyFactory.create('autodesk.tests:property.traversal-1.0.0'); property.push(element); @@ -583,8 +581,8 @@ describe('BaseProperty', function () { }); }); - it('two different properties should not be related', function () { - return createRootProperty().then(function (workspace) { + it('two different properties should not be related', function() { + return createRootProperty().then(function(workspace) { var prop1 = PropertyFactory.create('autodesk.tests:property.traversal-1.0.0'); var prop2 = PropertyFactory.create('autodesk.tests:property.traversal-1.0.0'); workspace.insert('test1', prop1); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/containerProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/containerProperty.spec.js index f908a3ea676a..6bd5e3116bd1 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/containerProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/containerProperty.spec.js @@ -3,7 +3,7 @@ * Licensed under the MIT License. */ -/* globals targets*/ +/* globals targets */ /* eslint-disable no-unused-expressions */ /* eslint-disable consistent-return */ /** @@ -11,31 +11,29 @@ * this will also tests parts of Property Factory that creates Container property */ - +const MSG = require('@fluid-experimental/property-common').constants.MSG; const PropertyFactory = require('../..').PropertyFactory; -const MSG = require('@fluid-experimental/property-common').constants.MSG - -describe('ContainerProperty', function () { +describe('ContainerProperty', function() { beforeEach(() => { PropertyFactory._clear(); }); - describe('Changeset', function () { - it('should not add created properties to the changeset on creation', function () { + describe('Changeset', function() { + it('should not add created properties to the changeset on creation', function() { const DefaultPrimitive = { typeid: 'SimpleTest:OptionalPrimitive-1.0.0', properties: [ { id: 'num', typeid: 'Uint32' }, { id: 'bool', typeid: 'Bool' }, - { id: 'string', typeid: 'String' } - ] + { id: 'string', typeid: 'String' }, + ], }; const changeset = { Uint32: { num: 0 }, Bool: { bool: false }, - String: { string: '' } + String: { string: '' }, }; PropertyFactory._reregister(DefaultPrimitive); @@ -45,22 +43,22 @@ describe('ContainerProperty', function () { expect(instance._serialize(true, false)).to.be.empty; }); - it('should add optional properties that have default values to the changeset on creation', function () { + it('should add optional properties that have default values to the changeset on creation', function() { const DefaultPrimitive = { typeid: 'SimpleTest:OptionalPrimitive-1.0.0', properties: [ { id: 'num', typeid: 'Uint32', value: 111, optional: true }, { id: 'bool', typeid: 'Bool', value: true, optional: true }, - { id: 'string', typeid: 'String', value: 'basic', optional: true } - ] + { id: 'string', typeid: 'String', value: 'basic', optional: true }, + ], }; const changeset = { insert: { Uint32: { num: 111 }, Bool: { bool: true }, - String: { string: 'basic' } - } + String: { string: 'basic' }, + }, }; PropertyFactory._reregister(DefaultPrimitive); @@ -69,14 +67,14 @@ describe('ContainerProperty', function () { expect(instance._serialize(true, false)).to.deep.equal(changeset); }); - it('should not add optional properties that do not have default values to the changeset on creation', function () { + it('should not add optional properties that do not have default values to the changeset on creation', function() { const DefaultPrimitive = { typeid: 'SimpleTest:OptionalPrimitive-1.0.0', properties: [ { id: 'num', typeid: 'Uint32', optional: true }, { id: 'bool', typeid: 'Bool', optional: true }, - { id: 'string', typeid: 'String', optional: true } - ] + { id: 'string', typeid: 'String', optional: true }, + ], }; PropertyFactory._reregister(DefaultPrimitive); @@ -86,15 +84,15 @@ describe('ContainerProperty', function () { }); }); - describe('Optional Properties', function () { - it('should not exist on creation if no value is specified', function () { + describe('Optional Properties', function() { + it('should not exist on creation if no value is specified', function() { const DefaultPrimitive = { typeid: 'SimpleTest:OptionalPrimitive-1.0.0', properties: [ { id: 'num', typeid: 'Uint32', optional: true }, { id: 'bool', typeid: 'Bool', optional: true }, - { id: 'string', typeid: 'String', optional: true } - ] + { id: 'string', typeid: 'String', optional: true }, + ], }; PropertyFactory._reregister(DefaultPrimitive); @@ -105,14 +103,14 @@ describe('ContainerProperty', function () { expect(instance.get('string')).to.be.undefined; }); - it('should exist on creation if value is specified', function () { + it('should exist on creation if value is specified', function() { const DefaultPrimitive = { typeid: 'SimpleTest:OptionalPrimitive-1.0.0', properties: [ { id: 'num', typeid: 'Uint32', value: 111, optional: true }, { id: 'bool', typeid: 'Bool', value: true, optional: true }, - { id: 'string', typeid: 'String', value: 'basic', optional: true } - ] + { id: 'string', typeid: 'String', value: 'basic', optional: true }, + ], }; PropertyFactory._reregister(DefaultPrimitive); @@ -123,14 +121,14 @@ describe('ContainerProperty', function () { expect(instance.get('string').getValue()).to.equal('basic'); }); - it('can be inserted', function () { + it('can be inserted', function() { const DefaultPrimitive = { typeid: 'SimpleTest:OptionalPrimitive-1.0.0', properties: [ { id: 'num', typeid: 'Uint32', optional: true }, { id: 'bool', typeid: 'Bool', optional: true }, - { id: 'string', typeid: 'String', optional: true } - ] + { id: 'string', typeid: 'String', optional: true }, + ], }; PropertyFactory._reregister(DefaultPrimitive); @@ -155,14 +153,14 @@ describe('ContainerProperty', function () { expect(instance.get('string').getValue()).to.equal('basic'); }); - it('can be removed', function () { + it('can be removed', function() { const DefaultPrimitive = { typeid: 'SimpleTest:OptionalPrimitive-1.0.0', properties: [ { id: 'num', typeid: 'Uint32', value: 111, optional: true }, { id: 'bool', typeid: 'Bool', value: true, optional: true }, - { id: 'string', typeid: 'String', value: 'basic', optional: true } - ] + { id: 'string', typeid: 'String', value: 'basic', optional: true }, + ], }; PropertyFactory._reregister(DefaultPrimitive); @@ -178,14 +176,14 @@ describe('ContainerProperty', function () { expect(instance.get('string')).to.be.undefined; }); - it('throws error if inserted property has unknown id', function () { + it('throws error if inserted property has unknown id', function() { const DefaultPrimitive = { typeid: 'SimpleTest:OptionalPrimitive-1.0.0', properties: [ { id: 'num', typeid: 'Uint32', value: 111, optional: true }, { id: 'bool', typeid: 'Bool', value: true, optional: true }, - { id: 'string', typeid: 'String', value: 'basic', optional: true } - ] + { id: 'string', typeid: 'String', value: 'basic', optional: true }, + ], }; PropertyFactory._reregister(DefaultPrimitive); @@ -196,14 +194,14 @@ describe('ContainerProperty', function () { expect(() => { instance.insert('badId', prop); }).to.throw(MSG.CANNOT_INSERT_UNKNOWN_PROPERTY + 'badId'); }); - it('throws error if inserted property typeid does not match corresponding typeid', function () { + it('throws error if inserted property typeid does not match corresponding typeid', function() { const DefaultPrimitive = { typeid: 'SimpleTest:OptionalPrimitive-1.0.0', properties: [ { id: 'num', typeid: 'Uint32', optional: true }, { id: 'bool', typeid: 'Bool', optional: true }, - { id: 'string', typeid: 'String', optional: true } - ] + { id: 'string', typeid: 'String', optional: true }, + ], }; PropertyFactory._reregister(DefaultPrimitive); @@ -214,14 +212,14 @@ describe('ContainerProperty', function () { expect(() => { instance.insert('num', prop); }).to.throw(MSG.MISMATCHING_PROPERTY_TYPEID); }); - it('throws error if attempting to remove a not optional property', function () { + it('throws error if attempting to remove a not optional property', function() { const DefaultPrimitive = { typeid: 'SimpleTest:OptionalPrimitive-1.0.0', properties: [ { id: 'num', typeid: 'Uint32', value: 111 }, { id: 'bool', typeid: 'Bool', value: true, optional: true }, - { id: 'string', typeid: 'String', value: 'basic', optional: true } - ] + { id: 'string', typeid: 'String', value: 'basic', optional: true }, + ], }; PropertyFactory._reregister(DefaultPrimitive); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/customArrayProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/customArrayProperty.spec.js index 7ae179bd095e..87c74a067687 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/customArrayProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/customArrayProperty.spec.js @@ -14,40 +14,40 @@ var possibleChanges = { 0: 'insert', 1: 'modify', 2: 'remove', - 3: 'set' + 3: 'set', }; -var createTestArrayProp = function () { +var createTestArrayProp = function() { return PropertyFactory.create('autodesk.tests:CustomArrayTestID-1.0.0')._properties.MyCustomArray; }; -var createRandomProperty = function () { +var createRandomProperty = function() { var node1 = PropertyFactory.create('autodesk.tests:TestID-1.0.0'); node1._properties.MyFloatProp.value = Math.random() * 100; node1._properties.MyIntProp.value = Math.random() * 100; return node1; }; -describe('CustomArrayProperty', function () { +describe('CustomArrayProperty', function() { /** * Get all the objects we need in this test here. */ - before(function () { + before(function() { PropertyFactory = require('../..').PropertyFactory; BaseProperty = require('../..').BaseProperty; DeterministicRandomGenerator = require('@fluid-experimental/property-common').DeterministicRandomGenerator; - ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet + ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet; _ = require('lodash'); deepCopy = _.cloneDeep; OurTestTemplate = { typeid: 'autodesk.tests:TestID-1.0.0', properties: [{ - id: 'MyFloatProp', typeid: 'Float32' + id: 'MyFloatProp', typeid: 'Float32', }, { - id: 'MyIntProp', typeid: 'Int32' - } - ] + id: 'MyIntProp', typeid: 'Int32', + }, + ], }; PropertyFactory._reregister(OurTestTemplate); @@ -55,8 +55,8 @@ describe('CustomArrayProperty', function () { typeid: 'autodesk.tests:CustomArrayTestID-1.0.0', properties: [ { id: 'MyCustomArray', typeid: 'autodesk.tests:TestID-1.0.0', context: 'array' }, - { id: 'SomeOtherProperty', typeid: 'String' } - ] + { id: 'SomeOtherProperty', typeid: 'String' }, + ], }; PropertyFactory._reregister(OurArrayTestTemplate2); @@ -64,14 +64,14 @@ describe('CustomArrayProperty', function () { typeid: 'autodesk.tests:Array.NamedPropertyWithString-1.0.0', inherits: 'NamedProperty', properties: [{ - id: 'stringProperty', typeid: 'String' - }] + id: 'stringProperty', typeid: 'String', + }], }; PropertyFactory._reregister(NamedPropertyWithStringTemplate); }); - describe('Checking the generalized squash function of a CustomPropertyArrayProperty', function () { - it('[random number test] should be squashed to the expected changeset', function (done) { + describe('Checking the generalized squash function of a CustomPropertyArrayProperty', function() { + it('[random number test] should be squashed to the expected changeset', function(done) { try { var arrayProp = createTestArrayProp(); @@ -123,14 +123,13 @@ describe('CustomArrayProperty', function () { var serializedDirtyChanges = arrayProp.serialize({ 'dirtyOnly': true, 'includeRootTypeid': false, - 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY + 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY, }); var arrayPropTest = createTestArrayProp(); arrayPropTest.deserialize(arrayPropCopy.serialize({ 'dirtyOnly': false })); arrayPropTest.cleanDirty(); arrayPropTest.applyChangeSet(serializedDirtyChanges); } - } catch (e) { error = e; } finally { @@ -143,8 +142,8 @@ describe('CustomArrayProperty', function () { }); }); - describe('Path resolution', function () { - it('should work for array properties', function () { + describe('Path resolution', function() { + it('should work for array properties', function() { var arrayParent = PropertyFactory.create('autodesk.tests:CustomArrayTestID-1.0.0'); var arrayProp = arrayParent._properties.MyCustomArray; @@ -171,7 +170,7 @@ describe('CustomArrayProperty', function () { expect(myTestArrayProp.getRelativePath(arrayProp)).to.equal('[5]'); // Test exception on parsing error - expect(function () { arrayParent.resolvePath('MyCustomArray["abcd"]'); }).to.throw(); + expect(function() { arrayParent.resolvePath('MyCustomArray["abcd"]'); }).to.throw(); // Test path resolution after insertion var newEntry = PropertyFactory.create('autodesk.tests:TestID-1.0.0'); @@ -197,21 +196,21 @@ describe('CustomArrayProperty', function () { insert: [[0, [{ typeid: 'autodesk.tests:TestID-1.0.0', Float32: { - MyFloatProp: 16 + MyFloatProp: 16, }, Int32: { - MyIntProp: 17 - } + MyIntProp: 17, + }, }, { typeid: 'autodesk.tests:TestID-1.0.0', Float32: { - MyFloatProp: 18 + MyFloatProp: 18, }, Int32: { - MyIntProp: 19 - } - }]] - ] + MyIntProp: 19, + }, + }]], + ], }); expect(arrayParent.resolvePath('MyCustomArray[0]')._properties.MyIntProp.value).to.equal(17); expect(myTestArrayProp.getAbsolutePath()).to.equal('/MyCustomArray[7]'); @@ -220,7 +219,7 @@ describe('CustomArrayProperty', function () { // Test path resolution after removal arrayParent._properties.MyCustomArray.applyChangeSet({ - remove: [[0, 1]] + remove: [[0, 1]], }); expect(arrayParent.resolvePath('MyCustomArray[0]')._properties.MyIntProp.value).to.equal(19); expect(myTestArrayProp.getAbsolutePath()).to.equal('/MyCustomArray[6]'); @@ -252,22 +251,22 @@ describe('CustomArrayProperty', function () { }); }); - describe('Sized arrays', function () { + describe('Sized arrays', function() { // Test fix for an issue where custom array templates with non-zero sizes // resulted in the array initially containing objects without a parent. - it('should work for custom array property templates with size specified', function () { + it('should work for custom array property templates with size specified', function() { var TestString = { typeid: 'autodesk.test:test.string-1.0.0', properties: [ - { id: 'data', typeid: 'String' } - ] + { id: 'data', typeid: 'String' }, + ], }; var TestCustomArray = { typeid: 'autodesk.test:test.customarray-1.0.0', properties: [ - { id: 'data', typeid: 'autodesk.test:test.string-1.0.0', context: 'array', length: 3 } - ] + { id: 'data', typeid: 'autodesk.test:test.string-1.0.0', context: 'array', length: 3 }, + ], }; PropertyFactory._reregister(TestString); PropertyFactory._reregister(TestCustomArray); @@ -275,15 +274,15 @@ describe('CustomArrayProperty', function () { var sizedArray = PropertyFactory.create('autodesk.test:test.customarray-1.0.0'); // Prior to the fix to properly parent initial elements, clear() would result in an exception with // the message 'Trying to remove a property from an array that has not the array as parent.' - var clearArrayFn = function () { + var clearArrayFn = function() { sizedArray.resolvePath('data').clear(); }; expect(clearArrayFn).to.not.throw(); }); }); - describe('Commit', function () { - /*it('should not appear in the changeset when committing a change on its sibling', function() { + describe('Commit', function() { + /* it('should not appear in the changeset when committing a change on its sibling', function() { // TODO: This test cannot be implemented in Fluid let cm = new HFDM(); let workspace = cm.createWorkspace(); @@ -307,10 +306,10 @@ describe('CustomArrayProperty', function () { checkoutView.getRoot().resolvePath('pset.SomeOtherProperty').setValue('foobar'); return cm._commit(null, checkoutView); }); - });*/ + }); */ - describe('Nested collections', function () { - it('should support squashing of nested maps', function () { + describe('Nested collections', function() { + it('should support squashing of nested maps', function() { var nodeProp = PropertyFactory.create('NodeProperty'); var arrayProp = PropertyFactory.create('array'); var testMap = PropertyFactory.create('map'); @@ -331,7 +330,7 @@ describe('CustomArrayProperty', function () { expect(arrayChanges.insert[0][1][0].insert['test']).to.equal(false); }); - it('should support basic rebasing of nested maps', function () { + it('should support basic rebasing of nested maps', function() { var nodeProp = PropertyFactory.create('NodeProperty'); var arrayProp = PropertyFactory.create('array'); var testMap = PropertyFactory.create('map'); @@ -353,7 +352,7 @@ describe('CustomArrayProperty', function () { expect(conflicts[0].path).to.be.equal('array[0][test]'); }); - it('should be deserializable', function () { + it('should be deserializable', function() { var testArray = PropertyFactory.create('array<>'); testArray.push(PropertyFactory.create('array<>')); var serialized = testArray.serialize({ 'dirtyOnly': false }); @@ -364,11 +363,10 @@ describe('CustomArrayProperty', function () { }); }); - describe('deserialize', function () { - + describe('deserialize', function() { // Returns a sequence of random NamedProperties - var createRandomEntries = function (in_count) { - return _.map(_.range(in_count), function () { + var createRandomEntries = function(in_count) { + return _.map(_.range(in_count), function() { var property = PropertyFactory.create('autodesk.tests:Array.NamedPropertyWithString-1.0.0'); property._properties.stringProperty.value = 'initial'; return property; @@ -378,10 +376,10 @@ describe('CustomArrayProperty', function () { // Manually copy the array (we don't use deserialize for the copy // here since we want to test that function below and don't want // an error here to affect the comparison) - var manuallyCopyArray = function (arrayProperty) { + var manuallyCopyArray = function(arrayProperty) { var copiedArray = PropertyFactory.create('autodesk.tests:Array.NamedPropertyWithString-1.0.0', 'array'); - var copiedEntries = _.map(arrayProperty.getEntriesReadOnly(), function (entry) { + var copiedEntries = _.map(arrayProperty.getEntriesReadOnly(), function(entry) { // Create a named property with the same guid var newNode = PropertyFactory.create('autodesk.tests:Array.NamedPropertyWithString-1.0.0'); newNode._properties.guid.value = entry.getGuid(); @@ -394,8 +392,7 @@ describe('CustomArrayProperty', function () { }; // Prepare the initial state - var initializeArrayForComparison = function (in_count) { - + var initializeArrayForComparison = function(in_count) { // Create an array with named properties var arrayProperty = PropertyFactory.create('NamedProperty', 'array'); var entries = createRandomEntries(in_count); @@ -405,12 +402,12 @@ describe('CustomArrayProperty', function () { return { original: arrayProperty, - copy: copiedArray + copy: copiedArray, }; }; // Counts the changes in the array - var countChanges = function (in_testArray) { + var countChanges = function(in_testArray) { // First create a copy of the copy to check afterwards whether the changeset is correct var copy2 = manuallyCopyArray(in_testArray.copy); @@ -428,17 +425,16 @@ describe('CustomArrayProperty', function () { in_testArray.original.serialize({ 'dirtyOnly': false })); // Count insert, modify and remove operations - var insertedCount = _.reduce(deserialized.insert, function (last, insertedRange) { + var insertedCount = _.reduce(deserialized.insert, function(last, insertedRange) { return last + insertedRange[1].length; }, 0); - var removedCount = _.reduce(deserialized.remove, function (last, removedRange) { + var removedCount = _.reduce(deserialized.remove, function(last, removedRange) { return last + removedRange[1]; }, 0); - var modifiedCount = _.reduce(deserialized.modify, function (last, modifiedRange) { + var modifiedCount = _.reduce(deserialized.modify, function(last, modifiedRange) { return last + modifiedRange[1].length; }, 0); - return { insertedCount: insertedCount, removedCount: removedCount, @@ -446,11 +442,11 @@ describe('CustomArrayProperty', function () { totalCount: insertedCount + removedCount + modifiedCount, insertedRanges: deserialized.insert ? deserialized.insert.length : 0, removedRanges: deserialized.remove ? deserialized.remove.length : 0, - modifiedRanges: deserialized.modify ? deserialized.modify.length : 0 + modifiedRanges: deserialized.modify ? deserialized.modify.length : 0, }; }; - it('should report an empty ChangeSet for deserialize without changes', function () { + it('should report an empty ChangeSet for deserialize without changes', function() { var testArray = initializeArrayForComparison(50); // Check the returned ChangeSet @@ -462,11 +458,11 @@ describe('CustomArrayProperty', function () { totalCount: 0, insertedRanges: 0, removedRanges: 0, - modifiedRanges: 0 + modifiedRanges: 0, }); }); - it('should report an empty ChangeSet for a length 0 array', function () { + it('should report an empty ChangeSet for a length 0 array', function() { var testArray = initializeArrayForComparison(0); // Check the returned ChangeSet @@ -478,18 +474,18 @@ describe('CustomArrayProperty', function () { totalCount: 0, insertedRanges: 0, removedRanges: 0, - modifiedRanges: 0 + modifiedRanges: 0, }); }); - it('should report a compact ChangeSet for simple move in an array of NamedProperties', function () { + it('should report a compact ChangeSet for simple move in an array of NamedProperties', function() { var testArray = initializeArrayForComparison(50); // Move a segment in the array var entries = [ testArray.original.get(45), testArray.original.get(46), - testArray.original.get(47) + testArray.original.get(47), ]; testArray.original.removeRange(45, 3); testArray.original.insertRange(3, entries); @@ -503,11 +499,11 @@ describe('CustomArrayProperty', function () { totalCount: 6, insertedRanges: 1, removedRanges: 1, - modifiedRanges: 0 + modifiedRanges: 0, }); }); - it('should report a compact ChangeSet for simple inserts in an array of NamedProperties', function () { + it('should report a compact ChangeSet for simple inserts in an array of NamedProperties', function() { var testArray = initializeArrayForComparison(50); testArray.original.insertRange(0, createRandomEntries(5)); @@ -522,11 +518,11 @@ describe('CustomArrayProperty', function () { totalCount: 15, insertedRanges: 3, removedRanges: 0, - modifiedRanges: 0 + modifiedRanges: 0, }); }); - it('should report a compact ChangeSet for simple removes in an array of NamedProperties', function () { + it('should report a compact ChangeSet for simple removes in an array of NamedProperties', function() { var testArray = initializeArrayForComparison(50); testArray.original.removeRange(0, 5); @@ -541,11 +537,11 @@ describe('CustomArrayProperty', function () { totalCount: 15, insertedRanges: 0, removedRanges: 3, - modifiedRanges: 0 + modifiedRanges: 0, }); }); - it('should report a compact ChangeSet for simple replaces in an array of NamedProperties', function () { + it('should report a compact ChangeSet for simple replaces in an array of NamedProperties', function() { var testArray = initializeArrayForComparison(50); testArray.original.removeRange(0, 5); @@ -565,11 +561,11 @@ describe('CustomArrayProperty', function () { totalCount: 30, insertedRanges: 3, removedRanges: 3, - modifiedRanges: 0 + modifiedRanges: 0, }); }); - it('should report a compact ChangeSet for modifies after inserts and removes', function () { + it('should report a compact ChangeSet for modifies after inserts and removes', function() { var testArray = initializeArrayForComparison(50); testArray.original.removeRange(5, 5); @@ -587,11 +583,11 @@ describe('CustomArrayProperty', function () { totalCount: 14, insertedRanges: 1, removedRanges: 1, - modifiedRanges: 2 + modifiedRanges: 2, }); }); - it('should report a compact ChangeSet for a randomized array of NamedProperties', function () { + it('should report a compact ChangeSet for a randomized array of NamedProperties', function() { var generator = new DeterministicRandomGenerator('931cff4d-392f-2f41-5c52-2e17965270dc'); this.timeout(90000); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/enumArrayProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/enumArrayProperty.spec.js index 5add5e5dc5a5..9e81b8e7bc70 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/enumArrayProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/enumArrayProperty.spec.js @@ -2,28 +2,28 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /** * @fileoverview In this file, we will test the functions of a EnumArrayProperty object * described in /src/properties/enumArrayProperty.js */ var PropertyFactory, MSG; -describe('EnumArrayProperty', function () { +describe('EnumArrayProperty', function() { /** * Get all the objects we need in this test here. */ - before(function () { - MSG = require('@fluid-experimental/property-common').constants.MSG + before(function() { + MSG = require('@fluid-experimental/property-common').constants.MSG; PropertyFactory = require('../..').PropertyFactory; const enumUnoDosTresSchema = { inherits: 'Enum', properties: [ { id: 'uno', value: 1 }, { id: 'dos', value: 2 }, - { id: 'tres', value: 3 } + { id: 'tres', value: 3 }, ], - typeid: 'autodesk.enum:unoDosTres-1.0.0' + typeid: 'autodesk.enum:unoDosTres-1.0.0', }; const enumAndEnumArraySchema = { @@ -32,36 +32,36 @@ describe('EnumArrayProperty', function () { context: 'array', id: 'enumArray', typeid: 'autodesk.enum:unoDosTres-1.0.0', - value: [2, 1, 2] - } + value: [2, 1, 2], + }, ], - typeid: 'autodesk.enum:enums-1.0.0' + typeid: 'autodesk.enum:enums-1.0.0', }; PropertyFactory._reregister(enumUnoDosTresSchema); PropertyFactory._reregister(enumAndEnumArraySchema); }); - it('Should be able to get a value', function () { + it('Should be able to get a value', function() { let property = PropertyFactory.create('autodesk.enum:enums-1.0.0'); expect(property.get('enumArray').get(0)).to.equal(2); expect(property.get('enumArray').getEnumString(0)).to.equal('dos'); }); - it('Should be able to getValues', function () { + it('Should be able to getValues', function() { let property = PropertyFactory.create('autodesk.enum:enums-1.0.0'); expect(property.get('enumArray').getValues()).to.deep.equal([2, 1, 2]); }); - it('Should be able to getEnumStrings', function () { + it('Should be able to getEnumStrings', function() { let property = PropertyFactory.create('autodesk.enum:enums-1.0.0'); expect(property.get('enumArray').getEnumStrings(0, 3)).to.deep.equal(['dos', 'uno', 'dos']); }); - it('Should be able to set a value using an Enum number', function () { + it('Should be able to set a value using an Enum number', function() { let property = PropertyFactory.create('autodesk.enum:enums-1.0.0'); expect(property.get('enumArray').get(0)).to.equal(2); @@ -69,14 +69,14 @@ describe('EnumArrayProperty', function () { expect(property.get('enumArray').get(0)).to.equal(1); }); - it('Should throw on setting invalid Enum number', function () { + it('Should throw on setting invalid Enum number', function() { let property = PropertyFactory.create('autodesk.enum:enums-1.0.0'); - expect(function () { + expect(function() { property.get('enumArray').set(0, -100); }).to.throw(MSG.UNKNOWN_ENUM); }); - it('Should be able to set a value using an Enum string', function () { + it('Should be able to set a value using an Enum string', function() { let property = PropertyFactory.create('autodesk.enum:enums-1.0.0'); expect(property.get('enumArray').get(0)).to.equal(2); @@ -84,42 +84,42 @@ describe('EnumArrayProperty', function () { expect(property.get('enumArray').get(0)).to.equal(1); }); - it('Should throw on setting invalid Enum string', function () { + it('Should throw on setting invalid Enum string', function() { let property = PropertyFactory.create('autodesk.enum:enums-1.0.0'); - expect(function () { + expect(function() { property.get('enumArray').set(0, 'badString'); }).to.throw(MSG.UNKNOWN_ENUM); }); - it('Should be able to insert a value using an Enum number', function () { + it('Should be able to insert a value using an Enum number', function() { let property = PropertyFactory.create('autodesk.enum:enums-1.0.0'); property.get('enumArray').insertRange(2, [1]); expect(property.get('enumArray').getValues()).to.deep.equal([2, 1, 1, 2]); }); - it('Should throw on inserting invalid Enum number', function () { + it('Should throw on inserting invalid Enum number', function() { let property = PropertyFactory.create('autodesk.enum:enums-1.0.0'); - expect(function () { + expect(function() { property.get('enumArray').insertRange(0, [-100]); }).to.throw(MSG.UNKNOWN_ENUM); }); - it('Should be able to insert a value using an Enum string', function () { + it('Should be able to insert a value using an Enum string', function() { let property = PropertyFactory.create('autodesk.enum:enums-1.0.0'); property.get('enumArray').insertRange(2, ['uno']); expect(property.get('enumArray').getValues()).to.deep.equal([2, 1, 1, 2]); }); - it('Should throw on inserting invalid Enum string', function () { + it('Should throw on inserting invalid Enum string', function() { let property = PropertyFactory.create('autodesk.enum:enums-1.0.0'); - expect(function () { + expect(function() { property.get('enumArray').insertRange(0, ['badString']); }).to.throw(MSG.UNKNOWN_ENUM); }); - it('Should be able to overide default values on creation with initialValues', function () { + it('Should be able to overide default values on creation with initialValues', function() { let initialValues = { 'enumArray': [3, 2, 3] }; let property = PropertyFactory.create('autodesk.enum:enums-1.0.0', null, initialValues); @@ -127,7 +127,7 @@ describe('EnumArrayProperty', function () { expect(property.get('enumArray').getEnumStrings(0, 3)).to.deep.equal(['tres', 'dos', 'tres']); }); - it('.getValidEnumList should return expected enum list', function () { + it('.getValidEnumList should return expected enum list', function() { var property = PropertyFactory.create('autodesk.enum:enums-1.0.0'); var enumList = property.get('enumArray').getValidEnumList(); expect(enumList).to.have.nested.property('uno.value', 1); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/enumProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/enumProperty.spec.js index b6cabaee8252..8e45068584c6 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/enumProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/enumProperty.spec.js @@ -2,7 +2,7 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /** * @fileoverview In this file, we will test the functions of a EnumProperty object * described in /src/properties/enumProperty.js @@ -11,19 +11,18 @@ var PropertyFactory, TestEnumTemplate, TestInlineEnumTemplate, TestEnumArrayTemplate, BaseProperty, ChangeSet, TestBaseContainingEnumTemplate, MSG, deepCopy, _; -describe('Test EnumProperty', function () { +describe('Test EnumProperty', function() { /** * Get all the objects we need in this test here. */ - before(function () { + before(function() { PropertyFactory = require('../..').PropertyFactory; BaseProperty = require('../..').BaseProperty; - ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet - MSG = require('@fluid-experimental/property-common').constants.MSG + ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet; + MSG = require('@fluid-experimental/property-common').constants.MSG; _ = require('lodash'); deepCopy = _.cloneDeep; - // the following templates are copies from the specification // disableling the single quote rule to keep exact copies TestEnumTemplate = { @@ -33,8 +32,8 @@ describe('Test EnumProperty', function () { properties: [ { id: "m", value: 1, annotation: { description: "meter" } }, { id: "cm", value: 2, annotation: { description: "centimeter" } }, - { id: "mm", value: 3, annotation: { description: "millimeter" } } - ] + { id: "mm", value: 3, annotation: { description: "millimeter" } }, + ], }; PropertyFactory._reregister(TestEnumTemplate); @@ -48,8 +47,8 @@ describe('Test EnumProperty', function () { properties: [ { id: "solid", value: 100, annotation: { description: "solid line" } }, { id: "dashed", value: 200, annotation: { description: "dashed line" } }, - { id: "dotted", value: 300, annotation: { description: "dotted line" } } - ] + { id: "dotted", value: 300, annotation: { description: "dotted line" } }, + ], }, { id: "style", @@ -59,8 +58,8 @@ describe('Test EnumProperty', function () { typeid: "Uint32", annotation: { description: "border thickness in Pixels", - unit: "Adsk.Core:Units.Imaging-1.0.0" - } + unit: "Adsk.Core:Units.Imaging-1.0.0", + }, }, { id: "secondLevelInlineEnum", @@ -68,12 +67,12 @@ describe('Test EnumProperty', function () { properties: [ { id: "A", value: 0, annotation: { description: "The Letter A." } }, { id: "B", value: 76596785, annotation: { description: "The Letter B." } }, - { id: "C", value: -199999, annotation: { description: "The Letter C." } } - ] - } - ] - } - ] + { id: "C", value: -199999, annotation: { description: "The Letter C." } }, + ], + }, + ], + }, + ], }; PropertyFactory._reregister(TestInlineEnumTemplate); @@ -81,22 +80,22 @@ describe('Test EnumProperty', function () { TestBaseContainingEnumTemplate = { typeid: 'autodesk.core:CustomWithEnumID-1.0.0', properties: [{ - id: 'MyEnum', typeid: 'autodesk.core:UnitsEnum-1.0.0' - } - ] + id: 'MyEnum', typeid: 'autodesk.core:UnitsEnum-1.0.0', + }, + ], }; PropertyFactory._reregister(TestBaseContainingEnumTemplate); TestEnumArrayTemplate = { typeid: 'autodesk.core:EnumArrayTestID-1.0.0', properties: [{ - id: 'MyEnumArray', typeid: 'autodesk.core:UnitsEnum-1.0.0', context: 'array' - }] + id: 'MyEnumArray', typeid: 'autodesk.core:UnitsEnum-1.0.0', context: 'array', + }], }; PropertyFactory._reregister(TestEnumArrayTemplate); }); - it('@bugFix should not modify the registered template', function () { + it('@bugFix should not modify the registered template', function() { let enumTemplate = { typeid: "autodesk.core:testEnum-1.0.0", annotation: { description: "The metric units" }, @@ -106,10 +105,10 @@ describe('Test EnumProperty', function () { properties: [ { id: "m", value: 1, annotation: { description: "meter" } }, { id: "cm", value: 2, annotation: { description: "centimeter" } }, - { id: "mm", value: 3, annotation: { description: "millimeter" } } - ] - } - ] + { id: "mm", value: 3, annotation: { description: "millimeter" } }, + ], + }, + ], }; let copyOfTemplate = deepCopy(enumTemplate); PropertyFactory._reregister(enumTemplate); @@ -117,8 +116,7 @@ describe('Test EnumProperty', function () { expect(PropertyFactory.getTemplate(copyOfTemplate.typeid).serialize()).to.deep.equal(copyOfTemplate); }); - it('should correctly set/get the Enum values', function () { - + it('should correctly set/get the Enum values', function() { var enumProp = PropertyFactory.create('autodesk.core:UnitsEnum-1.0.0'); enumProp.setEnumByString('cm'); @@ -149,21 +147,21 @@ describe('Test EnumProperty', function () { expect(firstOne).to.deep.equal(anotherOne); }); - it('should throw on setting invalid Enum strings', function () { + it('should throw on setting invalid Enum strings', function() { var enumProp = PropertyFactory.create('autodesk.core:UnitsEnum-1.0.0'); - expect(function () { + expect(function() { enumProp.setEnumByString('BadGuy'); }).to.throw(); }); - it('should throw on setting invalid Enum values', function () { + it('should throw on setting invalid Enum values', function() { var enumProp = PropertyFactory.create('autodesk.core:UnitsEnum-1.0.0'); - expect(function () { + expect(function() { enumProp.setValue(23); }).to.throw(); }); - it('should correctly squash Enums', function () { + it('should correctly squash Enums', function() { var enum1 = PropertyFactory.create('autodesk.core:CustomWithEnumID-1.0.0'); enum1._properties.MyEnum.value = 1; var squashedChangeset = new ChangeSet(enum1.serialize({ 'dirtyOnly': false })); @@ -176,17 +174,17 @@ describe('Test EnumProperty', function () { expect(serializedChangeset).to.deep.equal(squashedChangeset.getSerializedChangeSet()); }); - it('should have a default value that is the lowest valid value', function () { + it('should have a default value that is the lowest valid value', function() { var enumProp = PropertyFactory.create('autodesk.core:CustomWithEnumID-1.0.0'); expect(enumProp.get('MyEnum').value).to.equal(1); }); - it('should have a default value of 0 if 0 is a valid value', function () { + it('should have a default value of 0 if 0 is a valid value', function() { var enumProp = PropertyFactory.create('Adsk.Core:UI.Border-1.0.0'); expect(enumProp.get('style').get('secondLevelInlineEnum').value).to.equal(0); }); - it('should be possible to dynamically add an Enum to a NodeProperty', function () { + it('should be possible to dynamically add an Enum to a NodeProperty', function() { var enumProp = PropertyFactory.create('autodesk.core:UnitsEnum-1.0.0'); var myNode = PropertyFactory.create('NodeProperty'); myNode.insert('myEnum', enumProp); @@ -200,7 +198,7 @@ describe('Test EnumProperty', function () { expect(myNode.serialize({ 'dirtyOnly': false })).to.deep.equal(myNodeCopy.serialize({ 'dirtyOnly': false })); }); - it('should correctly rebase Properties containing Enum values and correctly show conflicts', function () { + it('should correctly rebase Properties containing Enum values and correctly show conflicts', function() { var baseProperty1 = PropertyFactory.create('autodesk.core:CustomWithEnumID-1.0.0'); // Create two copies of this state @@ -230,8 +228,8 @@ describe('Test EnumProperty', function () { // check result expect(changeSet1.getSerializedChangeSet()).to.deep.equal({ 'enum': { - MyEnum: 2 - } + MyEnum: 2, + }, }); expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); @@ -239,7 +237,7 @@ describe('Test EnumProperty', function () { expect(conflicts[0].conflictingChange['enum'].MyEnum).to.be.equal(2); }); - it('specialized EnumArrayProperty should work correctly', function () { + it('specialized EnumArrayProperty should work correctly', function() { var enum1 = PropertyFactory.create('autodesk.core:EnumArrayTestID-1.0.0'); var enumArray = enum1._properties.MyEnumArray; enumArray.insertRange(0, [1, 'cm', 'mm', 3]); @@ -249,13 +247,13 @@ describe('Test EnumProperty', function () { expect(enumArray.serialize()).to.deep.equal( { 'insert': [ - [0, [2, 1, 3]] - ] - } + [0, [2, 1, 3]], + ], + }, ); }); - it('.setRange should throw an error when in_offset is not an integer', function () { + it('.setRange should throw an error when in_offset is not an integer', function() { var enum1 = PropertyFactory.create('autodesk.core:EnumArrayTestID-1.0.0'); var enumArray = enum1._properties.MyEnumArray; enumArray.insertRange(0, [1, 'cm', 'mm']); @@ -263,7 +261,7 @@ describe('Test EnumProperty', function () { .to.throw(MSG.NOT_NUMBER); }); - it('.setRange should throw an error when in_array is not an array', function () { + it('.setRange should throw an error when in_array is not an array', function() { var enum1 = PropertyFactory.create('autodesk.core:EnumArrayTestID-1.0.0'); var enumArray = enum1._properties.MyEnumArray; enumArray.insertRange(0, [1, 'cm', 'mm']); @@ -271,7 +269,7 @@ describe('Test EnumProperty', function () { .to.throw(MSG.IN_ARRAY_NOT_ARRAY + 'EnumArrayProperty.setRange'); }); - it('.set should throw an error when in_offset is not an integer', function () { + it('.set should throw an error when in_offset is not an integer', function() { var enum1 = PropertyFactory.create('autodesk.core:EnumArrayTestID-1.0.0'); var enumArray = enum1._properties.MyEnumArray; enumArray.insertRange(0, [1, 'cm', 'mm']); @@ -279,19 +277,19 @@ describe('Test EnumProperty', function () { .to.throw(MSG.NOT_NUMBER); }); - it('.set should throw an error when in_value is an array', function () { + it('.set should throw an error when in_value is an array', function() { var enum1 = PropertyFactory.create('autodesk.core:EnumArrayTestID-1.0.0'); var enumArray = enum1._properties.MyEnumArray; enumArray.insertRange(0, [1, 'cm', 'mm']); expect(() => { enumArray.set(2, ['m']); }).to.throw(MSG.VALUE_STRING_OR_NUMBER); }); - it('isPrimitiveType should evaluate to true', function () { + it('isPrimitiveType should evaluate to true', function() { var enum1 = PropertyFactory.create(TestEnumTemplate.typeid); expect(enum1.isPrimitiveType()).to.equal(true); }); - it('.getValidEnumList should return expected enum list', function () { + it('.getValidEnumList should return expected enum list', function() { var enumProp = PropertyFactory.create('autodesk.core:UnitsEnum-1.0.0'); var enumList = enumProp.getValidEnumList(); expect(enumList).to.have.nested.property('m.value', 1); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/float32.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/float32.spec.js index f22b1bdd75a2..213bb5f39cfd 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/float32.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/float32.spec.js @@ -6,18 +6,18 @@ * @fileoverview In this file, we will test Float32 * object described in /src/properties/float32.js */ -describe('Float32', function () { +describe('Float32', function() { var Float32Property; /** * Get all the objects we need in this test here. */ - before(function () { + before(function() { Float32Property = require('../../properties/floatProperties').Float32Property; }); - describe('Checking the value stored in ValueProperty', function () { - it('should return the same value', function (done) { + describe('Checking the value stored in ValueProperty', function() { + it('should return the same value', function(done) { var fp; var error; const value = 100; diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/int64ArrayProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/int64ArrayProperty.spec.js index daa9b7efbe38..a7844b1f9431 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/int64ArrayProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/int64ArrayProperty.spec.js @@ -2,31 +2,31 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /** * @fileoverview In this file, we will test the Int64ArrayProperty * object described in /src/properties/arrayProperty.js */ -describe('Int64ArrayProperty', function () { +describe('Int64ArrayProperty', function() { var PropertyFactory, BaseProperty, ChangeSet, MSG; var changeSetWithEntries, removalChangeSet; var myInt64Prop, Int64; - before(function () { + before(function() { // Get all the objects we need in this test here. PropertyFactory = require('../..').PropertyFactory; BaseProperty = require('../..').BaseProperty; - ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet + ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet; Int64 = require('@fluid-experimental/property-common').Int64; - MSG = require('@fluid-experimental/property-common').constants.MSG + MSG = require('@fluid-experimental/property-common').constants.MSG; // Register a template with a set property for the tests var SimpleInt64TestPropertyTemplate = { typeid: 'autodesk.tests:SimpleInt64TestProperty-1.0.0', properties: [ - { id: 'int64Property', typeid: 'Int64', context: 'array' } - ] + { id: 'int64Property', typeid: 'Int64', context: 'array' }, + ], }; PropertyFactory._reregister(SimpleInt64TestPropertyTemplate); @@ -34,31 +34,28 @@ describe('Int64ArrayProperty', function () { }); // Inserts an Int64 value into the array - var insertInt64Value = function (int64Prop) { + var insertInt64Value = function(int64Prop) { int64Prop.insertRange(0, [new Int64(0, 1)]); }; // Removes the first element from the array - var removeArrayElement = function (int64Prop) { + var removeArrayElement = function(int64Prop) { int64Prop.removeRange(0, 1); }; // Modifies an array value - var modifyInt64Value = function (int64Prop) { + var modifyInt64Value = function(int64Prop) { int64Prop.setRange(0, [new Int64(0, 2)]); }; - - - describe('Testing creation, assignment and serialization', function () { - - it('should be empty at the beginning', function () { + describe('Testing creation, assignment and serialization', function() { + it('should be empty at the beginning', function() { expect(myInt64Prop.length).to.equal(0); expect(myInt64Prop.serialize({ 'dirtyOnly': true })).to.be.empty; expect(myInt64Prop.serialize({ 'dirtyOnly': false })).to.be.empty; }); - it('should be possible to insert into the 64 bit array', function () { + it('should be possible to insert into the 64 bit array', function() { // Text insertion myInt64Prop.insertRange(0, [new Int64(1, 2), '12345678987654321']); expect(myInt64Prop.get(0)).to.deep.equal(new Int64(1, 2)); @@ -71,7 +68,7 @@ describe('Int64ArrayProperty', function () { { insert: [[0, [[1, 2], [1653732529, 2874452], [5, 0]]]] }); }); - it('should be possible to set values in the 64 bit array', function () { + it('should be possible to set values in the 64 bit array', function() { myInt64Prop.setRange(0, [1, '123', new Int64(2, 2)]); expect(myInt64Prop.get(0)).to.deep.equal(new Int64(1, 0)); myInt64Prop.setRange(2, [new Int64(4, 5)]); @@ -82,31 +79,31 @@ describe('Int64ArrayProperty', function () { { insert: [[0, [[1, 0], [123, 0], [4, 5]]]] }); }); - it('.setRange should throw an error when in_offset is not an integer', function () { + it('.setRange should throw an error when in_offset is not an integer', function() { expect(() => { myInt64Prop.setRange('test', [new Int64(2, 2)]); }) .to.throw(MSG.NOT_NUMBER); }); - it('.setRange should throw an error when in_array is not an array', function () { + it('.setRange should throw an error when in_array is not an array', function() { expect(() => { myInt64Prop.setRange(0, new Int64(2, 2)); }) .to.throw(MSG.IN_ARRAY_NOT_ARRAY + 'Int64ArrayProperty.setRange'); }); - it('Should handle removals correctly', function () { + it('Should handle removals correctly', function() { myInt64Prop.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY); myInt64Prop.removeRange(0, 2); expect(myInt64Prop.get(0)).to.deep.equal(new Int64(4, 5)); removalChangeSet = myInt64Prop.serialize({ 'dirtyOnly': true, 'includeRootTypeid': false, - 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY + 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY, }); expect(removalChangeSet).to.have.all.keys(['remove']); expect(removalChangeSet.remove).to.have.length(1); expect(removalChangeSet.remove[0]).to.deep.equal([0, 2]); }); - it('Should support deserialization', function () { + it('Should support deserialization', function() { var deserializedNode = PropertyFactory.create('Int64', 'array'); var deserializedChanges1 = deserializedNode.deserialize(changeSetWithEntries); expect(deserializedChanges1).to.deep.equal(changeSetWithEntries); @@ -115,13 +112,13 @@ describe('Int64ArrayProperty', function () { expect(deserializedChanges3).to.deep.equal({ remove: [[0, 3]] }); }); - it('inserting at a bad position should throw an exception', function () { - expect(function () { + it('inserting at a bad position should throw an exception', function() { + expect(function() { myInt64Prop.insertRange(2242, new Int64(4, 5)); }).to.throw(); }); - it('Should support applying changeset', function () { + it('Should support applying changeset', function() { var node = PropertyFactory.create('Int64', 'array'); node._applyChangeset(changeSetWithEntries); expect(node.get(0)).to.deep.equal(new Int64(1)); @@ -130,37 +127,35 @@ describe('Int64ArrayProperty', function () { }); }); - describe('change set specification should be met', function () { - - it('Should handle push correctly', function () { + describe('change set specification should be met', function() { + it('Should handle push correctly', function() { var t = PropertyFactory.create('Int64', 'array'); t.insertRange(0, [new Int64(1, 2), new Int64(3, 4)]); t.cleanDirty(); t.push(new Int64(4, 5)); expect(t.serialize({ 'dirtyOnly': true })).to.deep.equal( { - 'insert': [[2, [[4, 5]]]] - } + 'insert': [[2, [[4, 5]]]], + }, ); }); - it('Should handle modifies correctly', function () { + it('Should handle modifies correctly', function() { var t = PropertyFactory.create('Int64', 'array'); t.insertRange(0, [new Int64(1, 2), new Int64(3, 4)]); t.cleanDirty(); t.set(1, new Int64(4, 5)); expect(t.serialize({ 'dirtyOnly': true })).to.deep.equal( { - 'modify': [[1, [[4, 5]]]] - } + 'modify': [[1, [[4, 5]]]], + }, ); }); }); - - describe('squashing', function () { + describe('squashing', function() { // Helper function to test the squashing for different containers - var innerTestChangeSetSquashing = function (io_testProperty, io_int64Property, + var innerTestChangeSetSquashing = function(io_testProperty, io_int64Property, io_initialChangeset, in_options, in_collection) { var squashedChangeset = new ChangeSet(); io_initialChangeset.setIsNormalized(true); @@ -193,8 +188,7 @@ describe('Int64ArrayProperty', function () { // Optionally, a a callback which controls the initial state before the squashing can // be given as first parameter // - var testChangeSetSquashing = function (in_options) { - + var testChangeSetSquashing = function(in_options) { var testProperty = PropertyFactory.create('autodesk.tests:SimpleInt64TestProperty-1.0.0'); if (in_options.pre) { @@ -218,63 +212,60 @@ describe('Int64ArrayProperty', function () { } }; - it('should work for multiple independent inserts', function () { + it('should work for multiple independent inserts', function() { testChangeSetSquashing({ callbacks: [insertInt64Value, insertInt64Value, insertInt64Value] }); }); - it('should work for inserts followed by removes', function () { + it('should work for inserts followed by removes', function() { testChangeSetSquashing({ callbacks: [insertInt64Value, insertInt64Value, removeArrayElement, removeArrayElement], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('should work for mixed modifies and inserts', function () { + it('should work for mixed modifies and inserts', function() { testChangeSetSquashing({ - callbacks: [insertInt64Value, modifyInt64Value, insertInt64Value, modifyInt64Value] + callbacks: [insertInt64Value, modifyInt64Value, insertInt64Value, modifyInt64Value], }); }); - it('an insert, modify and a remove should give an empty changeset', function () { + it('an insert, modify and a remove should give an empty changeset', function() { testChangeSetSquashing({ callbacks: [insertInt64Value, modifyInt64Value, removeArrayElement], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('work for modifies after an already existing insert', function () { + it('work for modifies after an already existing insert', function() { testChangeSetSquashing({ pre: insertInt64Value, - callbacks: [modifyInt64Value, modifyInt64Value] + callbacks: [modifyInt64Value, modifyInt64Value], }); }); - it('of modify and remove after an already existing insert should work', function () { + it('of modify and remove after an already existing insert should work', function() { testChangeSetSquashing({ pre: insertInt64Value, callbacks: [modifyInt64Value, removeArrayElement], - post: function (changeset) { + post: function(changeset) { expect(changeset['array'].int64Property).to.have.all.keys('remove'); - } + }, }); }); - }); - - describe('Rebasing', function () { - - var createPropertyForRebaseTestByTemplate = function () { + describe('Rebasing', function() { + var createPropertyForRebaseTestByTemplate = function() { return PropertyFactory.create('autodesk.tests:SimpleInt64TestProperty-1.0.0'); }; - var getint64PropertyFromNode = function (in_testProperty) { + var getint64PropertyFromNode = function(in_testProperty) { return in_testProperty._properties.int64Property; }; - var testRebasingInner = function (in_creator, in_getInnerProperty, in_options, in_isCollection) { + var testRebasingInner = function(in_creator, in_getInnerProperty, in_options, in_isCollection) { // Prepare the initial state var baseProperty1 = in_creator(); if (in_options.prepare) { @@ -348,159 +339,156 @@ describe('Int64ArrayProperty', function () { } }; - var testRebasing = function (in_options) { + var testRebasing = function(in_options) { testRebasingInner(createPropertyForRebaseTestByTemplate, getint64PropertyFromNode, in_options); }; - it('with a NOP should be possible', function () { + it('with a NOP should be possible', function() { testRebasing({ op2: insertInt64Value, - compareToSequential: true + compareToSequential: true, }); }); - it('with independent inserts should be possible', function () { + it('with independent inserts should be possible', function() { testRebasing({ op1: insertInt64Value, op2: insertInt64Value, - compareToSequential: true + compareToSequential: true, }); }); - it('with independent removes should be possible', function () { + it('with independent removes should be possible', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { insertInt64Value(root); insertInt64Value(root); }, - op1: function (root) { + op1: function(root) { root.removeRange(1, 1); }, - op2: function (root) { + op2: function(root) { root.removeRange(0, 1); }, - compareToSequential: true + compareToSequential: true, }); }); - it('with a modify and a remove should possible', function () { + it('with a modify and a remove should possible', function() { testRebasing({ prepare: insertInt64Value, op1: modifyInt64Value, op2: removeArrayElement, - compareToSequential: true + compareToSequential: true, }); }); - it('with a remove and a modify should possible', function () { - + it('with a remove and a modify should possible', function() { testRebasing({ prepare: insertInt64Value, op1: removeArrayElement, op2: modifyInt64Value, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFIED_AFTER_REMOVE); expect(conflicts[0].path).to.be.equal('int64Property'); - } + }, }); }); - it('with two compatible removes should be possible', function () { + it('with two compatible removes should be possible', function() { testRebasing({ prepare: insertInt64Value, op1: removeArrayElement, op2: removeArrayElement, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; - } + }, }); }); - it('with two independent modifies should be possible', function () { + it('with two independent modifies should be possible', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root.insertRange(0, [new Int64(9, 8), new Int64(11, 21)]); }, op1: modifyInt64Value, - op2: function (root) { + op2: function(root) { root.setRange(1, [new Int64(5, 6)]); }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.be.empty; - } + }, }); }); - it('with two conflicting modifies should be possible and report a conflict', function () { + it('with two conflicting modifies should be possible and report a conflict', function() { testRebasing({ prepare: insertInt64Value, - op1: function (int64Prop) { + op1: function(int64Prop) { int64Prop.setRange(0, [new Int64(0, 64)]); }, op2: modifyInt64Value, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(changeSet['array'].int64Property.modify[0][1]).to.deep.equal([[0, 2]]); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('int64Property'); - } + }, }); }); - it('with modify followed by remove+insert should work', function () { + it('with modify followed by remove+insert should work', function() { testRebasing({ prepare: insertInt64Value, op1: modifyInt64Value, - op2: function (root) { + op2: function(root) { removeArrayElement(root); insertInt64Value(root); }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.REMOVE_AFTER_MODIFY); expect(conflicts[0].path).to.be.equal('int64Property'); expect(changeSet['array'].int64Property).to.have.all.keys('remove', 'insert'); - } + }, }); }); - it('with remove + insert followed by modify should report conflict', function () { + it('with remove + insert followed by modify should report conflict', function() { testRebasing({ prepare: insertInt64Value, - op1: function (root) { + op1: function(root) { removeArrayElement(root); insertInt64Value(root); }, op2: modifyInt64Value, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFIED_AFTER_REMOVE); expect(conflicts[0].path).to.be.equal('int64Property'); - } + }, }); }); - it('with conflicting inserts should report conflict', function () { + it('with conflicting inserts should report conflict', function() { testRebasing({ prepare: insertInt64Value, op1: insertInt64Value, op2: insertInt64Value, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.INSERTED_ENTRY_WITH_SAME_KEY); expect(conflicts[0].path).to.be.equal('int64Property'); - } + }, }); }); - }); - }); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/int64MapProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/int64MapProperty.spec.js index 838bafc23844..59cb8653e6a5 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/int64MapProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/int64MapProperty.spec.js @@ -3,20 +3,20 @@ * Licensed under the MIT License. */ /* globals describe */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /** * @fileoverview In this file, we will test the int64 map property * object described in /src/properties/valueMapProperty.js */ -describe('Int64MapProperty', function () { +describe('Int64MapProperty', function() { var PropertyFactory, BaseProperty, ChangeSet, myNode, Int64Map, Int64; - before(function () { + before(function() { // Get all the objects we need in this test here. PropertyFactory = require('../..').PropertyFactory; BaseProperty = require('../..').BaseProperty; - ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet + ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet; Int64 = require('@fluid-experimental/property-common').Int64; // Register a template with a set property for the tests @@ -24,25 +24,24 @@ describe('Int64MapProperty', function () { typeid: 'autodesk.tests:Int64MapTestPropertyID-1.0.0', inherits: ['NamedProperty'], properties: [ - { id: 'Int64Map', typeid: 'Int64', context: 'map' } - ] + { id: 'Int64Map', typeid: 'Int64', context: 'map' }, + ], }; PropertyFactory._reregister(TestPropertyTemplate); myNode = PropertyFactory.create('autodesk.tests:Int64MapTestPropertyID-1.0.0'); Int64Map = myNode._properties.Int64Map; - }); // Helper functions for the test cases var keyCounter = 0; - var resetKeyCounter = function () { + var resetKeyCounter = function() { keyCounter = 0; }; // Inserts a node with a given key (a new one is generated when undefined) - var insertEntryInRootWithKey = function (key, root) { + var insertEntryInRootWithKey = function(key, root) { if (key === undefined) { key = 'node' + keyCounter++; } @@ -50,37 +49,37 @@ describe('Int64MapProperty', function () { }; // Inserts a new node in the root - var insertNodeInRoot = function (root) { + var insertNodeInRoot = function(root) { insertEntryInRootWithKey(undefined, root); }; // Returns a functor that will insert a node with a constant key - var insertEntryInRootWithUnqiueKey = function () { + var insertEntryInRootWithUnqiueKey = function() { var key = 'node' + keyCounter++; return insertEntryInRootWithKey.bind(undefined, key); }; // Removes the first node from the root - var removeFirstNodeInRoot = function (root) { + var removeFirstNodeInRoot = function(root) { var firstKey = root._properties.Int64Map.getIds()[0]; root._properties.Int64Map.remove(firstKey); }; // Modifies the first node - var modifyEntry = function (root) { + var modifyEntry = function(root) { var firstKey = root._properties.Int64Map.getIds()[0]; root._properties.Int64Map.set(firstKey, new Int64(1, root._properties.Int64Map.get(firstKey) + 1)); }; - describe('Testing creation, assignment and serialization', function () { - it('should be empty at the beginning', function () { + describe('Testing creation, assignment and serialization', function() { + it('should be empty at the beginning', function() { expect(Int64Map.getAsArray()).to.be.empty; expect(Int64Map.getEntriesReadOnly()).to.be.empty; expect(ChangeSet.isEmptyChangeSet(Int64Map.serialize({ 'dirtyOnly': false }))).to.be.ok; expect(ChangeSet.isEmptyChangeSet(Int64Map.serialize({ 'dirtyOnly': true }))).to.be.ok; }); - it('should be possible to add entries', function () { + it('should be possible to add entries', function() { Int64Map.insert('value1', new Int64(1, 1)); expect(Int64Map.get('value1')).to.deep.equal(new Int64(1, 1)); Int64Map.insert('value2', new Int64(1, 2)); @@ -94,7 +93,7 @@ describe('Int64MapProperty', function () { expect(Int64Map.getEntriesReadOnly()).to.deep.equal( { 'value1': new Int64(1, 1), 'value2': new Int64(1, 2), 'value3': new Int64(1, 3), - 'value4': new Int64(123, 0), 'value5': new Int64(123, 0) + 'value4': new Int64(123, 0), 'value5': new Int64(123, 0), }); expect(Int64Map.has('value1')).to.be.ok; @@ -104,11 +103,11 @@ describe('Int64MapProperty', function () { expect(Int64Map.has('value5')).to.be.ok; expect(Int64Map.serialize({ 'dirtyOnly': false })).to.deep.equal({ - insert: { 'value1': [1, 1], 'value2': [1, 2], 'value3': [1, 3], 'value4': [123, 0], 'value5': [123, 0] } + insert: { 'value1': [1, 1], 'value2': [1, 2], 'value3': [1, 3], 'value4': [123, 0], 'value5': [123, 0] }, }); }); - it('should be possible to remove entries', function () { + it('should be possible to remove entries', function() { Int64Map.remove('value1'); expect(Int64Map.has('value1')).to.be.not.ok; Int64Map.remove('value2'); @@ -122,7 +121,7 @@ describe('Int64MapProperty', function () { expect(ChangeSet.isEmptyChangeSet(Int64Map.serialize({ 'dirtyOnly': false }))).to.be.ok; }); - it('a remove followed by an insert should become a modify', function () { + it('a remove followed by an insert should become a modify', function() { Int64Map.insert('value1', new Int64(1, 1)); Int64Map.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY | BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE); @@ -130,13 +129,13 @@ describe('Int64MapProperty', function () { Int64Map.insert('value1', new Int64(1, 2)); expect(Int64Map.serialize({ 'dirtyOnly': true })).to.deep.equal({ - modify: { 'value1': [1, 2] } + modify: { 'value1': [1, 2] }, }); // This should also work for a set operation Int64Map.set('value1', new Int64(1, 3)); expect(Int64Map.serialize({ 'dirtyOnly': true })).to.deep.equal({ - modify: { 'value1': [1, 3] } + modify: { 'value1': [1, 3] }, }); // But setting the same value should give an empty ChangeSet @@ -155,22 +154,21 @@ describe('Int64MapProperty', function () { expect(Int64Map.serialize({ 'dirtyOnly': true, 'includeRootTypeid': false, - 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE + 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE, })).to.deep.equal({ - modify: { 'value1': [1, 2] } + modify: { 'value1': [1, 2] }, }); expect(Int64Map.serialize({ 'dirtyOnly': true, 'includeRootTypeid': false, - 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY + 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY, })).to.deep.equal({ - insert: { 'value1': [1, 2] } + insert: { 'value1': [1, 2] }, }); - }); - it('deserialize should work', function () { + it('deserialize should work', function() { var myInitialStateNode = PropertyFactory.create('autodesk.tests:Int64MapTestPropertyID-1.0.0'); myInitialStateNode._properties.Int64Map.insert('value1', new Int64(1, 1)); myInitialStateNode._properties.Int64Map.insert('value2', new Int64(1, 2)); @@ -191,7 +189,6 @@ describe('Int64MapProperty', function () { myDeserializeNode2.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY | BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE); - myInitialStateNode.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY | BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE); myInitialStateNode._properties.Int64Map.set('value1', new Int64(1, 2)); @@ -211,15 +208,15 @@ describe('Int64MapProperty', function () { expect(deserializeChanges).to.deep.equal(changesChangeSet); }); - it('inserting the same key twice should throw an exception', function () { + it('inserting the same key twice should throw an exception', function() { var rootNode = PropertyFactory.create('autodesk.tests:Int64MapTestPropertyID-1.0.0'); rootNode._properties.Int64Map.insert('node1', new Int64(1, 1)); - expect(function () { + expect(function() { rootNode._properties.Int64Map.insert('node1', new Int64(1, 2)); }).to.throw(); }); - it('set should overwrite existing entry', function () { + it('set should overwrite existing entry', function() { var rootNode = PropertyFactory.create('autodesk.tests:Int64MapTestPropertyID-1.0.0'); rootNode._properties.Int64Map.set('node1', new Int64(1, 0)); @@ -238,10 +235,9 @@ describe('Int64MapProperty', function () { rootNode._properties.Int64Map.set('node1', new Int64(1, 2)); expect(rootNode.serialize({ 'dirtyOnly': true })['map'].Int64Map).to.have.all.keys('modify'); }); - }); - describe('squashing', function () { + describe('squashing', function() { // // Helper function which takes a sequence of callbacks that are suceessively executed // and the changes applied by the callbacks are separately tracked and squashed in a @@ -250,7 +246,7 @@ describe('Int64MapProperty', function () { // Optionally, a a callback which controls the initial state before the squashing can // be given as first parameter // - var testChangeSetSquashing = function (in_options) { + var testChangeSetSquashing = function(in_options) { resetKeyCounter(); var testProperty = PropertyFactory.create('autodesk.tests:Int64MapTestPropertyID-1.0.0'); @@ -282,68 +278,68 @@ describe('Int64MapProperty', function () { expect(initialChangeset.getSerializedChangeSet()).to.deep.equal(testProperty.serialize({ 'dirtyOnly': false })); }; - it('should work for multiple independent inserts', function () { + it('should work for multiple independent inserts', function() { testChangeSetSquashing({ callbacks: [insertNodeInRoot, insertNodeInRoot, insertNodeInRoot] }); }); - it('should work for inserts followed by removes', function () { + it('should work for inserts followed by removes', function() { testChangeSetSquashing({ callbacks: [insertNodeInRoot, insertNodeInRoot, removeFirstNodeInRoot, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('of inserts and modifies should work', function () { + it('of inserts and modifies should work', function() { testChangeSetSquashing({ - callbacks: [insertNodeInRoot, insertNodeInRoot, insertNodeInRoot, modifyEntry, modifyEntry] + callbacks: [insertNodeInRoot, insertNodeInRoot, insertNodeInRoot, modifyEntry, modifyEntry], }); }); - it('an insert, modify and a remove should give an empty changeset', function () { + it('an insert, modify and a remove should give an empty changeset', function() { testChangeSetSquashing({ callbacks: [insertNodeInRoot, modifyEntry, modifyEntry, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('should work for modifies after an already existing insert', function () { + it('should work for modifies after an already existing insert', function() { testChangeSetSquashing({ pre: insertNodeInRoot, - callbacks: [modifyEntry, modifyEntry] + callbacks: [modifyEntry, modifyEntry], }); }); - it('of modify and remove after an already existing insert should work', function () { + it('of modify and remove after an already existing insert should work', function() { testChangeSetSquashing({ pre: insertNodeInRoot, callbacks: [modifyEntry, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset['map'].Int64Map).to.have.all.keys('remove'); - } + }, }); }); - it('of remove and insert should result in modify', function () { + it('of remove and insert should result in modify', function() { // Create two nodes with the same GUID testChangeSetSquashing({ - pre: function (root) { + pre: function(root) { root._properties.Int64Map.insert('node1', new Int64(1, 1)); }, callbacks: [ removeFirstNodeInRoot, - function (root) { + function(root) { root._properties.Int64Map.insert('node1', new Int64(1, 2)); - } + }, ], - post: function (changeset) { + post: function(changeset) { expect(changeset['map'].Int64Map).to.have.all.keys('modify'); - } + }, }); }); }); - describe('Rebasing', function () { - var testRebasing = function (in_options) { + describe('Rebasing', function() { + var testRebasing = function(in_options) { // Prepare the initial state var baseProperty1 = PropertyFactory.create('autodesk.tests:Int64MapTestPropertyID-1.0.0'); if (in_options.prepare) { @@ -402,160 +398,160 @@ describe('Int64MapProperty', function () { } }; - it('with a NOP should be possible', function () { + it('with a NOP should be possible', function() { testRebasing({ op2: insertEntryInRootWithUnqiueKey(), - compareToSequential: true + compareToSequential: true, }); }); - it('with independent inserts should be possible', function () { + it('with independent inserts should be possible', function() { testRebasing({ op1: insertEntryInRootWithUnqiueKey(), op2: insertEntryInRootWithUnqiueKey(), - compareToSequential: true + compareToSequential: true, }); }); - it('with independent removes should be possible', function () { + it('with independent removes should be possible', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.Int64Map.insert('entry1', new Int64(1, 1)); root._properties.Int64Map.insert('entry2', new Int64(1, 2)); }, - op1: function (root) { + op1: function(root) { root._properties.Int64Map.remove('entry1'); }, - op2: function (root) { + op2: function(root) { root._properties.Int64Map.remove('entry2'); }, - compareToSequential: true + compareToSequential: true, }); }); - it('with a modify and a remove should possible', function () { + it('with a modify and a remove should possible', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.Int64Map.insert('entry1', new Int64(1, 1)); }, op1: modifyEntry, op2: removeFirstNodeInRoot, - compareToSequential: true + compareToSequential: true, }); }); - it('with a remove and a modify should possible', function () { + it('with a remove and a modify should possible', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.Int64Map.insert('entry1', new Int64(1, 1)); }, op1: removeFirstNodeInRoot, op2: modifyEntry, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFIED_AFTER_REMOVE); expect(conflicts[0].path).to.be.equal('Int64Map[entry1]'); expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; - } + }, }); }); - it('with two compatible removes should be possible', function () { + it('with two compatible removes should be possible', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.Int64Map.insert('entry1', new Int64(1, 1)); }, - op1: function (root) { + op1: function(root) { root._properties.Int64Map.remove('entry1'); }, - op2: function (root) { + op2: function(root) { root._properties.Int64Map.remove('entry1'); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; - } + }, }); }); - it('with two conflicting modifies should be possible and report a conflict', function () { + it('with two conflicting modifies should be possible and report a conflict', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.Int64Map.insert('entry1', new Int64(1, 1)); }, - op1: function (root) { + op1: function(root) { root._properties.Int64Map.set('entry1', new Int64(1, 2)); }, - op2: function (root) { + op2: function(root) { root._properties.Int64Map.set('entry1', new Int64(1, 3)); }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('Int64Map[entry1]'); - } + }, }); }); - it('with modify followed by remove+insert should be a conflicting set', function () { + it('with modify followed by remove+insert should be a conflicting set', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.Int64Map.insert('entry1', new Int64(1, 1)); }, op1: modifyEntry, - op2: function (root) { + op2: function(root) { root._properties.Int64Map.remove('entry1'); root._properties.Int64Map.insert('entry1', new Int64(1, 2)); }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('Int64Map[entry1]'); - } + }, }); }); - it('with remove+insert followed by modify should be a conflicting set', function () { + it('with remove+insert followed by modify should be a conflicting set', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.Int64Map.insert('entry1', new Int64(1, 1)); }, - op1: function (root) { + op1: function(root) { root._properties.Int64Map.remove('entry1'); root._properties.Int64Map.insert('entry1', new Int64(1, 2)); }, - op2: function (root) { + op2: function(root) { root._properties.Int64Map.set('entry1', new Int64(1, 3)); }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('Int64Map[entry1]'); - } + }, }); }); - it('with conflicting inserts should report conflict', function () { + it('with conflicting inserts should report conflict', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { }, - op1: function (root) { + op1: function(root) { root._properties.Int64Map.insert('entry1', new Int64(1, 1)); }, - op2: function (root) { + op2: function(root) { root._properties.Int64Map.insert('entry1', new Int64(1, 2)); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(changeSet['map'].Int64Map).to.have.all.keys('modify'); expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('Int64Map[entry1]'); - } + }, }); }); }); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/int64Property.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/int64Property.spec.js index 0b4940c1e0e0..6c51757a7114 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/int64Property.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/int64Property.spec.js @@ -12,24 +12,24 @@ var PropertyFactory, nodeProp, containedInt64Prop, directInt64Prop, Int64, Uint64, BaseProperty, ChangeSet, TestInt64ArrayTemplate, MSG; -describe('Test Int64Property', function () { +describe('Test Int64Property', function() { /** * Get all the objects we need in this test here. */ - before(function () { + before(function() { PropertyFactory = require('../..').PropertyFactory; BaseProperty = require('../..').BaseProperty; - ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet + ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet; Int64 = require('@fluid-experimental/property-common').Int64; Uint64 = require('@fluid-experimental/property-common').Uint64; - MSG = require('@fluid-experimental/property-common').constants.MSG + MSG = require('@fluid-experimental/property-common').constants.MSG; TestInt64ArrayTemplate = { typeid: 'autodesk.tests:Int64TestID-1.0.0', properties: [ { id: 'myInt64', typeid: 'Int64' }, - { id: 'myUint64', typeid: 'Uint64' } - ] + { id: 'myUint64', typeid: 'Uint64' }, + ], }; PropertyFactory._reregister(TestInt64ArrayTemplate); @@ -38,7 +38,7 @@ describe('Test Int64Property', function () { directInt64Prop = PropertyFactory.create('Int64'); }); - it('should correctly set/get the values', function () { + it('should correctly set/get the values', function() { containedInt64Prop.setValueHigh(33); containedInt64Prop.setValueLow(22); expect(containedInt64Prop.getValueLow()).to.be.equal(22); @@ -56,7 +56,7 @@ describe('Test Int64Property', function () { expect(containedInt64Prop.value.setValueHigh).to.not.exist; }); - it('should correctly setValue when passed a number', function () { + it('should correctly setValue when passed a number', function() { const prop = PropertyFactory.create('Int64'); const value = 123; prop.setValue(value); @@ -65,14 +65,14 @@ describe('Test Int64Property', function () { expect(prop.toString()).to.equal(value.toString()); }); - it('should correctly setValue when passed a negative number', function () { + it('should correctly setValue when passed a negative number', function() { const prop = PropertyFactory.create('Int64'); const value = -123; prop.setValue(value); expect(prop.toString()).to.equal(value.toString()); }); - it('should correctly setValue when passed a large number (above MAX_SAFE_INT)', function () { + it('should correctly setValue when passed a large number (above MAX_SAFE_INT)', function() { const prop = PropertyFactory.create('Int64'); const value = Math.pow(2, 53) - 1000; prop.setValue(value); @@ -82,7 +82,7 @@ describe('Test Int64Property', function () { expect(prop.getValueHigh()).to.equal(2097151); }); - it('should correctly setValue when passed a large negative number (below MIN_SAFE_INT)', function () { + it('should correctly setValue when passed a large negative number (below MIN_SAFE_INT)', function() { const prop = PropertyFactory.create('Int64'); const value = -Math.pow(2, 53) + 1000; prop.setValue(value); @@ -92,19 +92,18 @@ describe('Test Int64Property', function () { expect(prop.getValueHigh()).to.equal(-2097152); }); - it('should correctly setValue when passed a string', function () { + it('should correctly setValue when passed a string', function() { const prop = PropertyFactory.create('Int64'); prop.setValue('1234567890'); expect(prop.toString()).to.equal('1234567890'); }); - it('should throw error when passed a string with non numbers', function () { + it('should throw error when passed a string with non numbers', function() { const prop = PropertyFactory.create('Int64'); expect(prop.setValue.bind(prop, 'error')).to.throw(MSG.CANNOT_PARSE_INVALID_CHARACTERS + 'error'); }); - it('should correctly convert to string', function () { - + it('should correctly convert to string', function() { containedInt64Prop.value = new Int64(4294967295, 2147483647); // 2^63-1 expect(containedInt64Prop.toString()).to.be.equal('9223372036854775807'); @@ -127,7 +126,7 @@ describe('Test Int64Property', function () { expect(containedInt64Prop.toString()).to.be.equal('-1'); }); - it('int64.fromString should work correctly', function () { + it('int64.fromString should work correctly', function() { containedInt64Prop.value = new Int64(0, 0); expect(containedInt64Prop.toString()).to.be.equal('0'); @@ -150,7 +149,7 @@ describe('Test Int64Property', function () { expect(containedInt64Prop.value.getValueLow()).to.be.equal(0xFFFFFFFF); }); - it('should correctly serialize/deserialize', function () { + it('should correctly serialize/deserialize', function() { containedInt64Prop.value = new Int64(11, 12); var serialized = containedInt64Prop.serialize({ 'dirtyOnly': true }); @@ -172,7 +171,7 @@ describe('Test Int64Property', function () { expect(otherNodeProp._properties.myInt64.getValueHigh()).to.be.equal(12); }); - it('should correctly dirty on set', function () { + it('should correctly dirty on set', function() { directInt64Prop.cleanDirty(); expect(directInt64Prop.isDirty()).to.be.false; directInt64Prop.value = new Int64(32, 42); @@ -195,24 +194,24 @@ describe('Test Int64Property', function () { expect(directInt64Prop.isDirty()).to.be.false; }); - it('should not violate the ChangeSet Specificaton', function () { + it('should not violate the ChangeSet Specificaton', function() { containedInt64Prop.value = new Int64(32, 42); nodeProp._properties.myUint64.value = new Uint64(99, 110); expect(nodeProp.serialize({ 'dirtyOnly': false })).to.deep.equal( { Int64: { - myInt64: [32, 42] + myInt64: [32, 42], }, Uint64: { - myUint64: [99, 110] - } - } + myUint64: [99, 110], + }, + }, ); }); - describe('squashing', function () { + describe('squashing', function() { // Helper function to test the squashing for different containers - var innerTestChangeSetSquashing = function (io_testProperty, io_intProperty, + var innerTestChangeSetSquashing = function(io_testProperty, io_intProperty, io_initialChangeset, in_options, in_collection) { var squashedChangeset = new ChangeSet(); io_testProperty.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY | @@ -243,8 +242,7 @@ describe('Test Int64Property', function () { // Optionally, a a callback which controls the initial state before the squashing can // be given as first parameter // - var testChangeSetSquashing = function (in_options) { - + var testChangeSetSquashing = function(in_options) { var testProperty = PropertyFactory.create('autodesk.tests:Int64TestID-1.0.0'); var nodeTestProperty = PropertyFactory.create('NodeProperty'); var int64InNodeProperty = PropertyFactory.create('Int64'); @@ -273,7 +271,6 @@ describe('Test Int64Property', function () { innerTestChangeSetSquashing(mapTestProperty, int64InMapProperty, initialChangesetMap, in_options, true); - var initialChangeset = initialChangeset.getSerializedChangeSet().Int64.intProperty; expect(initialChangeset).to.deep.equal(testProperty.serialize({ 'dirtyOnly': false }).Int64.intProperty); @@ -286,33 +283,33 @@ describe('Test Int64Property', function () { { 'dirtyOnly': false }).insert.Int64.intProperty); }; - it('should correctly squash 64bit properties', function () { + it('should correctly squash 64bit properties', function() { testChangeSetSquashing({ callbacks: [ - function (io_prop) { + function(io_prop) { io_prop.setValueHigh(1); }, - function (io_prop) { + function(io_prop) { io_prop.setValueHigh(2); - } - ] + }, + ], }); }); - it('should correctly squash low/high 64bit property changes', function () { + it('should correctly squash low/high 64bit property changes', function() { testChangeSetSquashing({ callbacks: [ - function (io_prop) { + function(io_prop) { io_prop.setValueHigh(1); }, - function (io_prop) { + function(io_prop) { io_prop.setValueLow(2); - } - ] + }, + ], }); }); - it('should squash two ChangeSets, one inserts the other modifies the same Int64 property', function () { + it('should squash two ChangeSets, one inserts the other modifies the same Int64 property', function() { var nodeTestProperty = PropertyFactory.create('NodeProperty'); var int64Property = PropertyFactory.create('Int64'); nodeTestProperty.insert('myProp', int64Property); @@ -333,12 +330,12 @@ describe('Test Int64Property', function () { expect( changeSet1.getSerializedChangeSet().insert.Int64.myProp === - changeSet2.getSerializedChangeSet().modify.Int64.myProp + changeSet2.getSerializedChangeSet().modify.Int64.myProp, ).to.be.false; expect(changeSet1.getSerializedChangeSet()).to.eql(expectedChangeSet); }); - it('should squash two ChangeSets, one inserts the other modifies the same Int64 property', function () { + it('should squash two ChangeSets, one inserts the other modifies the same Int64 property', function() { var nodeTestProperty = PropertyFactory.create('NodeProperty'); var Uint64Property = PropertyFactory.create('Uint64'); nodeTestProperty.insert('myProp', Uint64Property); @@ -359,40 +356,40 @@ describe('Test Int64Property', function () { expect( changeSet1.getSerializedChangeSet().insert.Uint64.myProp === - changeSet2.getSerializedChangeSet().modify.Uint64.myProp + changeSet2.getSerializedChangeSet().modify.Uint64.myProp, ).to.be.false; expect(changeSet1.getSerializedChangeSet()).to.eql(expectedChangeSet); }); }); - describe('rebasing', function () { - var createPropertyForRebaseTestByTemplate = function () { + describe('rebasing', function() { + var createPropertyForRebaseTestByTemplate = function() { return PropertyFactory.create('autodesk.tests:Int64TestID-1.0.0'); }; - var createNodePropertyForRebase = function () { + var createNodePropertyForRebase = function() { var nodeTestProperty = PropertyFactory.create('NodeProperty'); var int64InNodeProperty = PropertyFactory.create('Int64'); nodeTestProperty.insert('myInt64', int64InNodeProperty); return nodeTestProperty; }; - var createMapPropertyForRebase = function () { + var createMapPropertyForRebase = function() { var mapTestProperty = PropertyFactory.create('map<>'); var int64InNodeProperty = PropertyFactory.create('Int64'); mapTestProperty.insert('myInt64', int64InNodeProperty); return mapTestProperty; }; - var getIntPropertyFromNode = function (in_testProperty) { + var getIntPropertyFromNode = function(in_testProperty) { return in_testProperty._properties.myInt64; }; - var getIntPropertyFromMap = function (in_testProperty) { + var getIntPropertyFromMap = function(in_testProperty) { return in_testProperty.get('myInt64'); }; - var testRebasingInner = function (in_creator, in_getInnerProperty, in_options, in_isCollection) { + var testRebasingInner = function(in_creator, in_getInnerProperty, in_options, in_isCollection) { // Prepare the initial state var baseProperty1 = in_creator(); if (in_options.prepare) { @@ -454,7 +451,6 @@ describe('Test Int64Property', function () { } expect(combinedSerialized).to.deep.equal(finalChangeSet); - } if (in_options.checkResult) { @@ -465,43 +461,43 @@ describe('Test Int64Property', function () { } }; - var testRebasing = function (in_options) { + var testRebasing = function(in_options) { testRebasingInner(createPropertyForRebaseTestByTemplate, getIntPropertyFromNode, in_options); testRebasingInner(createNodePropertyForRebase, getIntPropertyFromNode, in_options, true); testRebasingInner(createMapPropertyForRebase, getIntPropertyFromMap, in_options, true); }; - it('with two modifies should be possible and report a conflict', function () { + it('with two modifies should be possible and report a conflict', function() { testRebasing({ - op1: function (io_prop) { + op1: function(io_prop) { io_prop.setValueHigh(1); }, - op2: function (io_prop) { + op2: function(io_prop) { io_prop.setValueHigh(2); }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(changeSet.Int64.myInt64).to.deep.equal([0, 2]); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); - } + }, }); }); - it('with low/high modifies should be possible and report a conflict', function () { + it('with low/high modifies should be possible and report a conflict', function() { testRebasing({ - op1: function (io_prop) { + op1: function(io_prop) { io_prop.setValueHigh(1); }, - op2: function (io_prop) { + op2: function(io_prop) { io_prop.setValueLow(2); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(changeSet.Int64.myInt64).to.deep.equal([2, 0]); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); - } + }, }); }); }); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/isLeafNode.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/isLeafNode.spec.js index 29fb797820da..cbed11f6393a 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/isLeafNode.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/isLeafNode.spec.js @@ -19,7 +19,7 @@ const AllProperties = { { id: 'const_int16', typeid: 'Int16', value: 111 }, { id: 'const_int32', typeid: 'Int32', value: 111 }, { id: 'const_bool', typeid: 'Bool', value: true }, - { id: 'const_string', typeid: 'String', value: 'This is a string' } + { id: 'const_string', typeid: 'String', value: 'This is a string' }, ], properties: [ { id: 'int8', typeid: 'Int8' }, @@ -37,26 +37,26 @@ const AllProperties = { id: 'nestedProps', properties: [ { id: 'string', typeid: 'String' }, - { id: 'bool', typeid: 'Bool' } - ] - } - ] + { id: 'bool', typeid: 'Bool' }, + ], + }, + ], }; -var createPropertyInsertAndCommit = function (workspace, typeid, context, propId) { +var createPropertyInsertAndCommit = function(workspace, typeid, context, propId) { const prop = PropertyFactory.create(typeid, context); workspace.insert(propId, prop); }; -describe('property-properties.Utils isLeafNode', function () { +describe('property-properties.Utils isLeafNode', function() { let root; /** * Get all the objects we need in this test here. */ - before(function () { + before(function() { PropertyFactory = require('../..').PropertyFactory; - ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet + ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet; _ = require('lodash'); deepCopy = _.cloneDeep; @@ -64,15 +64,15 @@ describe('property-properties.Utils isLeafNode', function () { PropertyFactory.register({ typeid: 'autodesk.tests:entry-1.0.0', properties: [ - { id: 'string', typeid: 'String' } - ] + { id: 'string', typeid: 'String' }, + ], }); PropertyFactory.register({ typeid: 'autodesk.tests:namedEntry-1.0.0', inherits: ['NamedProperty'], properties: [ - { id: 'string', typeid: 'String' } - ] + { id: 'string', typeid: 'String' }, + ], }); PropertyFactory.register({ typeid: 'autodesk.tests:array-1.0.0', @@ -80,10 +80,10 @@ describe('property-properties.Utils isLeafNode', function () { { id: 'array', typeid: 'autodesk.tests:entry-1.0.0', context: 'array', value: [ { string: 'I am a string 1' }, - { string: 'I am a string 2' } - ] - } - ] + { string: 'I am a string 2' }, + ], + }, + ], }); PropertyFactory.register({ typeid: 'autodesk.tests:set-1.0.0', @@ -91,10 +91,10 @@ describe('property-properties.Utils isLeafNode', function () { { id: 'set', typeid: 'autodesk.tests:namedEntry-1.0.0', context: 'set', value: [ { string: 'I am a string 1' }, - { string: 'I am a string 2' } - ] - } - ] + { string: 'I am a string 2' }, + ], + }, + ], }); PropertyFactory.register({ typeid: 'autodesk.tests:map-1.0.0', @@ -102,23 +102,23 @@ describe('property-properties.Utils isLeafNode', function () { { id: 'map', typeid: 'autodesk.tests:entry-1.0.0', context: 'map', value: { key1: { string: 'I am a string 1' }, - key2: { string: 'I am a string 2' } - } - } - ] + key2: { string: 'I am a string 2' }, + }, + }, + ], }); PsetUtils = require('@fluid-experimental/property-changeset').Utils; DeferredPromise = require('@fluid-experimental/property-common').DeferredPromise; }); - beforeEach(async function () { + beforeEach(async function() { root = PropertyFactory.create('NodeProperty'); }); - it.skip('should match leaf for primitives properties', async function () { + it.skip('should match leaf for primitives properties', async function() { let leafNodesCount = 0; - await createPropertyInsertAndCommit(root, 'mysample:all-1.0.0', 'single', 'singleProp'); + createPropertyInsertAndCommit(root, 'mysample:all-1.0.0', 'single', 'singleProp'); const changeSet = root.getRoot().serialize(); @@ -136,9 +136,9 @@ describe('property-properties.Utils isLeafNode', function () { expect(leafNodesCount).to.eql(19); }); - it('should see an empty array as a leaf', async function () { + it('should see an empty array as a leaf', async function() { let leafNodesCount = 0; - await createPropertyInsertAndCommit(root, 'mysample:all-1.0.0', 'array', 'arrayProp'); + createPropertyInsertAndCommit(root, 'mysample:all-1.0.0', 'array', 'arrayProp'); const changeSet = root.getRoot().serialize(); @@ -156,9 +156,9 @@ describe('property-properties.Utils isLeafNode', function () { expect(leafNodesCount).to.eql(1); }); - it('should see an empty map as a leaf', async function () { + it('should see an empty map as a leaf', async function() { let leafNodesCount = 0; - await createPropertyInsertAndCommit(root, 'mysample:all-1.0.0', 'map', 'mapProp'); + createPropertyInsertAndCommit(root, 'mysample:all-1.0.0', 'map', 'mapProp'); const changeSet = root.getRoot().serialize(); @@ -176,9 +176,9 @@ describe('property-properties.Utils isLeafNode', function () { expect(leafNodesCount).to.eql(1); }); - it('should see an empty set as a leaf', async function () { + it('should see an empty set as a leaf', async function() { let leafNodesCount = 0; - await createPropertyInsertAndCommit(root, 'mysample:all-1.0.0', 'set', 'setProp'); + createPropertyInsertAndCommit(root, 'mysample:all-1.0.0', 'set', 'setProp'); const changeSet = root.getRoot().serialize(); @@ -196,7 +196,7 @@ describe('property-properties.Utils isLeafNode', function () { expect(leafNodesCount).to.eql(1); }); - it('should count primitives in an array as leafs', async function () { + it('should count primitives in an array as leafs', async function() { let leafNodesCount = 0; const array = PropertyFactory.create('autodesk.tests:array-1.0.0'); root.insert('arrayProp', array); @@ -216,7 +216,7 @@ describe('property-properties.Utils isLeafNode', function () { expect(leafNodesCount).to.eql(2); }); - it('should count primitives in an set as leafs', async function () { + it('should count primitives in an set as leafs', async function() { let leafNodesCount = 0; const set = PropertyFactory.create('autodesk.tests:set-1.0.0'); root.insert('setProp', set); @@ -236,7 +236,7 @@ describe('property-properties.Utils isLeafNode', function () { expect(leafNodesCount).to.eql(4); }); - it('should count primitives in an map as leafs', async function () { + it('should count primitives in an map as leafs', async function() { let leafNodesCount = 0; const map = PropertyFactory.create('autodesk.tests:map-1.0.0'); root.insert('mapProp', map); @@ -256,7 +256,7 @@ describe('property-properties.Utils isLeafNode', function () { expect(leafNodesCount).to.eql(2); }); - it('should count remove as leafs in reversible changeset', async function () { + it('should count remove as leafs in reversible changeset', async function() { let leafNodesCount = 0; const map = PropertyFactory.create('autodesk.tests:map-1.0.0'); root.insert('mapProp', map); @@ -278,8 +278,7 @@ describe('property-properties.Utils isLeafNode', function () { expect(leafNodesCount).to.eql(1); }); - - it('should count remove as leafs', async function () { + it('should count remove as leafs', async function() { let leafNodesCount = 0; const map = PropertyFactory.create('autodesk.tests:map-1.0.0'); root.insert('mapProp', map); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/mapProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/mapProperty.spec.js index 8d7ea6e3c0ca..6e397c67570f 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/mapProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/mapProperty.spec.js @@ -2,22 +2,22 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /** * @fileoverview In this file, we will test the map property * object described in /src/properties/mapProperty.js */ -describe('MapProperty', function () { +describe('MapProperty', function() { var PropertyFactory, BaseProperty, ChangeSet, generateGuid, PATH_TOKENS; var changeSetWithTwoMapEntries, _, changeSetWithTwoMapEntries_full, removalChangeSet; var myNode, mapNode1, mapNode2, map; - before(function () { + before(function() { // Get all the objects we need in this test here. PropertyFactory = require('../..').PropertyFactory; BaseProperty = require('../..').BaseProperty; - ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet + ChangeSet = require('@fluid-experimental/property-changeset').ChangeSet; _ = require('lodash'); generateGuid = require('@fluid-experimental/property-common').GuidUtils.generateGUID; PATH_TOKENS = require('../..').BaseProperty.PATH_TOKENS; @@ -29,35 +29,35 @@ describe('MapProperty', function () { properties: [ { id: 'stringProperty', typeid: 'String' }, { id: 'stringProperty2', typeid: 'String' }, - { id: 'map', context: 'map', typeid: 'NamedProperty' } - ] + { id: 'map', context: 'map', typeid: 'NamedProperty' }, + ], }; var AnonymousTestPropertyTemplate = { typeid: 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0', properties: [ - { id: 'stringProperty', typeid: 'String' } - ] + { id: 'stringProperty', typeid: 'String' }, + ], }; var PrimitiveMapPropertyTemplate = { typeid: 'autodesk.tests:PrimitiveMap-1.0.0', properties: [ - { id: 'map', context: 'map', typeid: 'Int32' } - ] + { id: 'map', context: 'map', typeid: 'Int32' }, + ], }; var NonPrimitiveMapPropertyTemplate = { typeid: 'autodesk.tests:NonPrimitiveMap-1.0.0', properties: [ - { typeid: 'autodesk.tests:StringProperty-1.0.0', id: 'map', context: 'map' } - ] + { typeid: 'autodesk.tests:StringProperty-1.0.0', id: 'map', context: 'map' }, + ], }; var StringPropertyTemplate = { typeid: 'autodesk.tests:StringProperty-1.0.0', properties: [ - { id: 'stringValue', typeid: 'String' } - ] + { id: 'stringValue', typeid: 'String' }, + ], }; var ComplexProperty = { @@ -65,10 +65,10 @@ describe('MapProperty', function () { properties: [ { id: 'nested', properties: [ - { id: 'data', typeid: 'Int32' } - ] - } - ] + { id: 'data', typeid: 'Int32' }, + ], + }, + ], }; var ComplexMap = { @@ -76,10 +76,10 @@ describe('MapProperty', function () { properties: [ { id: 'path', properties: [ - { id: 'map', typeid: 'autodesk.tests:ComplexProperty-1.0.0', context: 'map' } - ] - } - ] + { id: 'map', typeid: 'autodesk.tests:ComplexProperty-1.0.0', context: 'map' }, + ], + }, + ], }; PropertyFactory._reregister(TestPropertyTemplate); @@ -98,12 +98,12 @@ describe('MapProperty', function () { // Helper functions for the test cases var keyCounter = 0; - var resetKeyCounter = function () { + var resetKeyCounter = function() { keyCounter = 0; }; // Inserts a node with the given guid (a new one is generated when undefined) - var insertNodeInRootWithKeyAndGuid = function (key, guid, root) { + var insertNodeInRootWithKeyAndGuid = function(key, guid, root) { var node = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); if (key === undefined) { key = 'node' + keyCounter++; @@ -115,18 +115,18 @@ describe('MapProperty', function () { }; // Inserts a new node in the root - var insertNodeInRoot = function (root) { + var insertNodeInRoot = function(root) { insertNodeInRootWithKeyAndGuid(undefined, undefined, root); }; // Returns a function that will insert a node with a constant GUID - var insertUniqueNodeInRoot = function () { + var insertUniqueNodeInRoot = function() { var key = 'node' + keyCounter++; return insertNodeInRootWithKeyAndGuid.bind(undefined, key, generateGuid()); }; // Inserts a new node as leaf - var insertNodeAsLeaf = function (root) { + var insertNodeAsLeaf = function(root) { var leaf = root; while (leaf._properties.map.getAsArray().length > 0) { leaf = leaf._properties.map.getAsArray()[0]; @@ -137,13 +137,13 @@ describe('MapProperty', function () { }; // Removes the first node from the root - var removeFirstNodeInRoot = function (root) { + var removeFirstNodeInRoot = function(root) { var firstKey = root._properties.map.getIds()[0]; root._properties.map.remove(firstKey); }; // Modifies the leaf node - var modifyLeaf = function (root) { + var modifyLeaf = function(root) { var leaf = root; while (leaf._properties.map.getAsArray().length > 0) { leaf = leaf._properties.map.getAsArray()[0]; @@ -151,14 +151,14 @@ describe('MapProperty', function () { leaf._properties.stringProperty.value = leaf._properties.stringProperty.value + '+'; }; - describe('API methods', function () { + describe('API methods', function() { var myMap, stringProp1, stringProp2; - before(function () { + before(function() { myMap = PropertyFactory.create('autodesk.tests:NonPrimitiveMap-1.0.0')._properties.map; stringProp1 = PropertyFactory.create('autodesk.tests:StringProperty-1.0.0'); stringProp2 = PropertyFactory.create('autodesk.tests:StringProperty-1.0.0'); }); - it('.clear should work', function () { + it('.clear should work', function() { myMap.insert('one', stringProp1); myMap.insert('two', stringProp2); expect(myMap.getEntriesReadOnly()).to.deep.equal({ 'one': stringProp1, 'two': stringProp2 }); @@ -166,29 +166,29 @@ describe('MapProperty', function () { expect(myMap.getEntriesReadOnly()).to.be.empty; }); - it('.getAsArray should return an array of map values', function () { + it('.getAsArray should return an array of map values', function() { myMap.insert('one', stringProp1); myMap.insert('two', stringProp2); expect(myMap.getAsArray()).to.deep.equal([stringProp1, stringProp2]); }); - it('.getFullTypeid should return a string of the typeid with or without collection', function () { + it('.getFullTypeid should return a string of the typeid with or without collection', function() { expect(myMap.getFullTypeid()).to.equal('map'); // hideCollection: true expect(myMap.getFullTypeid(true)).to.equal('autodesk.tests:StringProperty-1.0.0'); }); - it('.getTypeid should return a string of the typeid', function () { + it('.getTypeid should return a string of the typeid', function() { expect(myMap.getTypeid()).to.equal('autodesk.tests:StringProperty-1.0.0'); }); - it('.getIds should return an array of map keys', function () { + it('.getIds should return an array of map keys', function() { myMap.insert('one', stringProp1); myMap.insert('two', stringProp2); expect(myMap.getIds()).to.deep.equal(['one', 'two']); }); - it('.remove should remove an item from a map and return the removed item', function () { + it('.remove should remove an item from a map and return the removed item', function() { myMap.insert('one', stringProp1); myMap.insert('two', stringProp2); myMap.remove('one'); @@ -196,22 +196,22 @@ describe('MapProperty', function () { expect(myMap.remove('two')).to.equal(stringProp2); }); - it('.getContext should return map', function () { + it('.getContext should return map', function() { expect(myMap.getContext()).to.equal('map'); }); - it('getId should return the id', function () { + it('getId should return the id', function() { expect(myMap.getId()).to.equal('map'); }); - afterEach(function () { + afterEach(function() { myMap.clear(); }); }); - describe('get and resolvePath', function () { + describe('get and resolvePath', function() { var complexMap, complexProperty1, complexProperty2; - before(function () { + before(function() { complexMap = PropertyFactory.create('autodesk.tests:ComplexMap-1.0.0')._properties.path.map; complexProperty1 = PropertyFactory.create('autodesk.tests:ComplexProperty-1.0.0'); complexProperty2 = PropertyFactory.create('autodesk.tests:ComplexProperty-1.0.0'); @@ -221,13 +221,13 @@ describe('MapProperty', function () { complexMap.insert('two', complexProperty2); }); - it('should resolve a simple path', function () { + it('should resolve a simple path', function() { expect(complexMap.resolvePath('one.nested.data').getValue()).to.equal(123); expect(complexMap.get('one').get('nested').get('data').getValue()).to.equal(123); expect(complexMap.get(['one', 'nested', 'data']).getValue()).to.equal(123); }); - it('should work with raise path tokens', function () { + it('should work with raise path tokens', function() { expect(complexMap.resolvePath('../../path.map.one')).to.deep.equal(complexProperty1); expect(complexMap.get(PATH_TOKENS.UP).get(PATH_TOKENS.UP).get('path') .get('map').get('two')).to.deep.equal(complexProperty2); @@ -235,7 +235,7 @@ describe('MapProperty', function () { .to.deep.equal(complexProperty2); }); - it('should work with root tokens', function () { + it('should work with root tokens', function() { expect(complexMap.resolvePath('/path.map.two')).to.deep.equal(complexProperty2); expect(complexMap.get(PATH_TOKENS.ROOT).get('path').get('map').get('two').get('nested') .get('data').getValue()).to.equal(456); @@ -243,14 +243,13 @@ describe('MapProperty', function () { }); }); - - describe('Testing creation, assignment and serialization', function () { - it('should be empty at the beginning', function () { + describe('Testing creation, assignment and serialization', function() { + it('should be empty at the beginning', function() { expect(map.getEntriesReadOnly()).to.be.empty; expect(map.serialize({ 'dirtyOnly': true })).to.be.empty; }); - it('should be possible to insert into the map', function () { + it('should be possible to insert into the map', function() { // Test insertion of the first node map.insert('node1', mapNode1); expect(map.has('node1')).to.be.ok; @@ -280,35 +279,35 @@ describe('MapProperty', function () { expect(changeSetWithTwoMapEntries).to.deep.equal(changeSetWithTwoMapEntries_full); }); - it('Should track dirtiness', function () { + it('Should track dirtiness', function() { map.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY); expect(map.serialize({ 'dirtyOnly': true, 'includeRootTypeid': false, - 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY + 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY, })).to.be.empty; expect(map.serialize({ 'dirtyOnly': true, 'includeRootTypeid': false, - 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE + 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE, })).deep.equal(changeSetWithTwoMapEntries_full); expect(map.serialize({ 'dirtyOnly': false })).deep.equal(changeSetWithTwoMapEntries_full); }); - it('Should handle removals correctly', function () { + it('Should handle removals correctly', function() { map.remove('node1'); expect(mapNode1.getParent()).to.be.undefined; map.remove('node2'); expect(map.serialize({ 'dirtyOnly': true, 'includeRootTypeid': false, - 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE + 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE, })).to.be.empty; expect(map.serialize({ 'dirtyOnly': false })).to.be.empty; removalChangeSet = map.serialize({ 'dirtyOnly': true, 'includeRootTypeid': false, - 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY + 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY, }); expect(removalChangeSet).to.have.all.keys(['remove']); expect(removalChangeSet.remove).to.have.length(2); @@ -316,7 +315,7 @@ describe('MapProperty', function () { expect(removalChangeSet.remove).to.contain('node2'); }); - it('Should support deserialization', function () { + it('Should support deserialization', function() { // Deserialization should return an identical property var deserializedNode = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var deserializedChanges1 = deserializedNode._properties.map.deserialize(changeSetWithTwoMapEntries); @@ -345,11 +344,11 @@ describe('MapProperty', function () { 'autodesk.tests:MapTestPropertyID-1.0.0': { 'node2': { 'String': { - 'stringProperty': 'newValue' - } - } - } - } + 'stringProperty': 'newValue', + }, + }, + }, + }, }; expect(deserializedChanges3).to.deep.equal(expectedChanges); expect(deserializedNode._properties.map.serialize({ 'dirtyOnly': true })).to.deep.equal(expectedChanges); @@ -360,18 +359,17 @@ describe('MapProperty', function () { expect(deserializedNode._properties.map.serialize({ 'dirtyOnly': true })).to.deep.equal(removalChangeSet); }); - it('Should support deserialization of falsy primitive types', function () { + it('Should support deserialization of falsy primitive types', function() { var testProp1 = PropertyFactory.create('map'); testProp1.set('entry', false); var changes = testProp1.deserialize(testProp1.serialize({ 'dirtyOnly': false })); expect(changes).to.be.empty; }); - it('Should track modifies', function () { + it('Should track modifies', function() { var modifyNode1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var modifyNode2 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); - modifyNode1._properties.map.deserialize(changeSetWithTwoMapEntries); modifyNode2._properties.map.deserialize(changeSetWithTwoMapEntries); @@ -385,7 +383,7 @@ describe('MapProperty', function () { .to.deep.equal(modifyNode1._properties.map.serialize({ 'dirtyOnly': false })); }); - it('Should support hierarchical properties', function () { + it('Should support hierarchical properties', function() { var node1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var node2 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var node3 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); @@ -418,7 +416,7 @@ describe('MapProperty', function () { expect(child2._properties.stringProperty.value).to.equal('test2'); }); - it('should be possible to use anonymous properties', function () { + it('should be possible to use anonymous properties', function() { var rootNode = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var rootNode2 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var node1 = PropertyFactory.create('autodesk.tests:AnonymousMapTestPropertyID-1.0.0'); @@ -440,17 +438,17 @@ describe('MapProperty', function () { expect(rootNode2.serialize({ 'dirtyOnly': false })).to.be.deep.equal(rootNode.serialize({ 'dirtyOnly': false })); }); - it('inserting the same key twice should throw an exception', function () { + it('inserting the same key twice should throw an exception', function() { var rootNode = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var node1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var node2 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); rootNode._properties.map.insert('node1', node1); - expect(function () { + expect(function() { rootNode._properties.map.insert('node1', node2); }).to.throw(); }); - it('set should overwrite existing entry', function () { + it('set should overwrite existing entry', function() { var rootNode = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var node1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var node2 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); @@ -475,35 +473,34 @@ describe('MapProperty', function () { rootNode._properties.map.set('node1', node3); expect(rootNode.serialize({ 'dirtyOnly': true })['map'].map).to.have.all.keys('insert', 'remove'); expect(rootNode.serialize({ 'dirtyOnly': true })['map'].map.remove).to.have.length(1); - }); - it('set should throw if the value inserted is not a property', function () { + it('set should throw if the value inserted is not a property', function() { var rootNode = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0')._properties.map; var node1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); rootNode.insert('node', node1); - var incorrectFn = function () { + var incorrectFn = function() { rootNode.set('node', 8); }; expect(incorrectFn).to.throw(); }); - it('insert should work when inserting a primitive value', function () { + it('insert should work when inserting a primitive value', function() { var rootNode = PropertyFactory.create('autodesk.tests:PrimitiveMap-1.0.0')._properties.map; rootNode.insert('node0', 1); - var correctFn = function () { + var correctFn = function() { rootNode.insert('node1', 4); }; expect(correctFn).to.not.throw(); }); - it('inserting the same node twice should be a bug', function () { + it('inserting the same node twice should be a bug', function() { var rootNode = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var node = PropertyFactory.create('autodesk.tests:AnonymousMapTestPropertyID-1.0.0'); // Try to insert the same node object under two keys rootNode._properties.map.insert('node', node); - expect(function () { + expect(function() { rootNode._properties.map.insert('node2', node); }).to.throw(); @@ -512,21 +509,21 @@ describe('MapProperty', function () { rootNode._properties.map.insert('node2', node); }); - it('setValues should work for primitive maps', function () { + it('setValues should work for primitive maps', function() { var node = PropertyFactory.create('autodesk.tests:AnonymousMapTestPropertyID-1.0.0'); node.setValues({ - 'stringProperty': 'newString!!' + 'stringProperty': 'newString!!', }); expect(node.get('stringProperty').getValue()).to.equal('newString!!'); }); - it('setValues should replace values for primitive types ', function () { + it('setValues should replace values for primitive types ', function() { var PrimitiveInt32MapTemplate = { typeid: 'autodesk.tests:PrimitiveInt32Map-1.0.0', properties: [ - { typeid: 'Int32', id: 'map', context: 'map' } - ] + { typeid: 'Int32', id: 'map', context: 'map' }, + ], }; PropertyFactory.register(PrimitiveInt32MapTemplate); @@ -541,15 +538,15 @@ describe('MapProperty', function () { node.setValues({ 'map': { - 'firstKey': 333 - } + 'firstKey': 333, + }, }); expect(node.get('map').getEntriesReadOnly().firstKey).to.equal(333); expect(node.get('map').getEntriesReadOnly().secondKey).to.equal(222); }); - it('getValues should work for primitive maps', function () { + it('getValues should work for primitive maps', function() { var rootNode = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var node = PropertyFactory.create('autodesk.tests:AnonymousMapTestPropertyID-1.0.0'); @@ -557,19 +554,19 @@ describe('MapProperty', function () { rootNode._properties.map.setValues({ 'node': { - 'stringProperty': 'newString!!' - } + 'stringProperty': 'newString!!', + }, }); var expectedResult = { node: { - 'stringProperty': 'newString!!' - } + 'stringProperty': 'newString!!', + }, }; expect(rootNode._properties.map.getValues()).to.deep.equal(expectedResult); }); - it('setValues should work for custom maps', function () { + it('setValues should work for custom maps', function() { var mapProp = PropertyFactory.create('autodesk.tests:NonPrimitiveMap-1.0.0'); var string1 = PropertyFactory.create('autodesk.tests:StringProperty-1.0.0'); var string2 = PropertyFactory.create('autodesk.tests:StringProperty-1.0.0'); @@ -579,12 +576,12 @@ describe('MapProperty', function () { mapProp.setValues({ 'map': { 'firstString': { - 'stringValue': 'test1' + 'stringValue': 'test1', }, 'secondString': { - 'stringValue': 'test2' - } - } + 'stringValue': 'test2', + }, + }, }); expect(mapProp.get(['map', 'firstString', 'stringValue']).getValue()).to.equal('test1'); @@ -594,21 +591,20 @@ describe('MapProperty', function () { expect(mapProp.get(['map', 'firstString', 'stringValue']).getValue()).to.equal('test1_updated'); expect(mapProp.get(['map', 'secondString', 'stringValue']).getValue()).to.equal('test2'); - }); - it('setValues should update values for existing keys and create new ones for non-existing keys', function () { + it('setValues should update values for existing keys and create new ones for non-existing keys', function() { var mapProp = PropertyFactory.create('autodesk.tests:NonPrimitiveMap-1.0.0'); mapProp.setValues({ 'map': { 'firstString': { - 'stringValue': 'test1' + 'stringValue': 'test1', }, 'secondString': { - 'stringValue': 'test2' - } - } + 'stringValue': 'test2', + }, + }, }); expect(mapProp.get(['map', 'firstString', 'stringValue']).getValue()).to.equal('test1'); @@ -617,12 +613,12 @@ describe('MapProperty', function () { mapProp.setValues({ 'map': { 'secondString': { - 'stringValue': 'test2-upd' + 'stringValue': 'test2-upd', }, 'thirdString': { - 'stringValue': 'test3' - } - } + 'stringValue': 'test3', + }, + }, }); expect(mapProp.get(['map', 'firstString', 'stringValue']).getValue()).to.equal('test1'); @@ -632,12 +628,12 @@ describe('MapProperty', function () { mapProp.setValues({ 'map': { 'fourthString': { - 'stringValue': 'test4' + 'stringValue': 'test4', }, 'thirdString': { - 'stringValue': 'test3-upd' - } - } + 'stringValue': 'test3-upd', + }, + }, }); expect(mapProp.get(['map', 'firstString', 'stringValue']).getValue()).to.equal('test1'); @@ -646,7 +642,7 @@ describe('MapProperty', function () { expect(mapProp.get(['map', 'fourthString', 'stringValue']).getValue()).to.equal('test4'); }); - it('getValues should work for custom maps', function () { + it('getValues should work for custom maps', function() { var mapProp = PropertyFactory.create('autodesk.tests:NonPrimitiveMap-1.0.0'); var string1 = PropertyFactory.create('autodesk.tests:StringProperty-1.0.0'); var string2 = PropertyFactory.create('autodesk.tests:StringProperty-1.0.0'); @@ -657,28 +653,28 @@ describe('MapProperty', function () { mapProp.setValues({ 'map': { 'firstString': { - 'stringValue': 'test1' + 'stringValue': 'test1', }, 'secondString': { - 'stringValue': 'test2' - } - } + 'stringValue': 'test2', + }, + }, }); var expectedResult = { 'map': { 'firstString': { - 'stringValue': 'test1' + 'stringValue': 'test1', }, 'secondString': { - 'stringValue': 'test2' - } - } + 'stringValue': 'test2', + }, + }, }; expect(mapProp.getValues()).to.deep.equal(expectedResult); }); - it('setValues should create new items from typed properties if key does not exist', function () { + it('setValues should create new items from typed properties if key does not exist', function() { var mapProp = PropertyFactory.create('autodesk.tests:NonPrimitiveMap-1.0.0'); var string1 = PropertyFactory.create('autodesk.tests:StringProperty-1.0.0', null, { stringValue: 'test1' }); var string2 = PropertyFactory.create('autodesk.tests:StringProperty-1.0.0', null, { stringValue: 'test2' }); @@ -686,44 +682,44 @@ describe('MapProperty', function () { mapProp.setValues({ 'map': { 'firstString': string1, - 'secondString': string2 - } + 'secondString': string2, + }, }); expect(mapProp.get(['map', 'firstString', 'stringValue']).getValue()).to.equal('test1'); expect(mapProp.get(['map', 'secondString', 'stringValue']).getValue()).to.equal('test2'); }); - it('setValues should create new items from untyped inputs if key does not exist', function () { + it('setValues should create new items from untyped inputs if key does not exist', function() { var mapProp = PropertyFactory.create('autodesk.tests:NonPrimitiveMap-1.0.0'); mapProp.setValues({ 'map': { 'firstString': { - 'stringValue': 'test1' + 'stringValue': 'test1', }, 'secondString': { - 'stringValue': 'test2' - } - } + 'stringValue': 'test2', + }, + }, }); expect(mapProp.get(['map', 'firstString', 'stringValue']).getValue()).to.equal('test1'); expect(mapProp.get(['map', 'secondString', 'stringValue']).getValue()).to.equal('test2'); }); - it('getRelativePath should work', function () { + it('getRelativePath should work', function() { var rootNode = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var mapProp = PropertyFactory.create('autodesk.tests:NonPrimitiveMap-1.0.0'); mapProp.setValues({ 'map': { 'firstString': { - 'stringValue': 'test1' + 'stringValue': 'test1', }, 'secondString': { - 'stringValue': 'test2' - } - } + 'stringValue': 'test2', + }, + }, }); rootNode._properties.map.insert('nestedMap', mapProp); expect(mapProp.get(['map', 'firstString']).getRelativePath(rootNode)) @@ -735,7 +731,7 @@ describe('MapProperty', function () { .to.equal('../../[firstString].stringValue'); }); - it('path creation and resolution should work for entries of the map', function () { + it('path creation and resolution should work for entries of the map', function() { var rootNode = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var node = PropertyFactory.create('autodesk.tests:AnonymousMapTestPropertyID-1.0.0'); rootNode._properties.map.insert('node', node); @@ -805,7 +801,7 @@ describe('MapProperty', function () { ' entry (Map of NodeProperty):\n' + ' entry (NodeProperty):\n'; var prettyStr = ''; - map3.prettyPrint(function (str) { + map3.prettyPrint(function(str) { prettyStr += str + '\n'; }); expect(prettyStr).to.equal(expectedPrettyStr); @@ -813,7 +809,7 @@ describe('MapProperty', function () { }); }); - describe('squashing', function () { + describe('squashing', function() { // // Helper function which takes a sequence of callbacks that are successfully executed // and the changes applied by the callbacks are separately tracked and squashed in a @@ -822,7 +818,7 @@ describe('MapProperty', function () { // Optionally, a a callback which controls the initial state before the squashing can // be given as first parameter // - var testChangeSetSquashing = function (in_options) { + var testChangeSetSquashing = function(in_options) { resetKeyCounter(); var testProperty = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); @@ -854,58 +850,58 @@ describe('MapProperty', function () { expect(initialChangeset.getSerializedChangeSet()).to.deep.equal(testProperty.serialize({ 'dirtyOnly': false })); }; - it('should work for multiple independent inserts', function () { + it('should work for multiple independent inserts', function() { testChangeSetSquashing({ callbacks: [insertNodeInRoot, insertNodeInRoot, insertNodeInRoot] }); }); - it('should work for multiple hierarchical inserts', function () { + it('should work for multiple hierarchical inserts', function() { testChangeSetSquashing({ callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, insertNodeAsLeaf] }); }); - it('should work for inserts followed by removes', function () { + it('should work for inserts followed by removes', function() { testChangeSetSquashing({ callbacks: [insertNodeInRoot, insertNodeInRoot, removeFirstNodeInRoot, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('should work for a tree removal', function () { + it('should work for a tree removal', function() { testChangeSetSquashing({ callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, insertNodeAsLeaf, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('should work for modifies in a tree', function () { + it('should work for modifies in a tree', function() { testChangeSetSquashing({ - callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, insertNodeAsLeaf, modifyLeaf, modifyLeaf] + callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, insertNodeAsLeaf, modifyLeaf, modifyLeaf], }); }); - it('an insert, modify and a remove should give an empty changeset', function () { + it('an insert, modify and a remove should give an empty changeset', function() { testChangeSetSquashing({ callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, modifyLeaf, modifyLeaf, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('work for modifies after an already existing insert', function () { + it('work for modifies after an already existing insert', function() { testChangeSetSquashing({ pre: insertNodeInRoot, - callbacks: [modifyLeaf, modifyLeaf] + callbacks: [modifyLeaf, modifyLeaf], }); }); - it('of modify and remove after an already existing insert should work', function () { + it('of modify and remove after an already existing insert should work', function() { testChangeSetSquashing({ pre: insertNodeInRoot, callbacks: [modifyLeaf, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset['map'].map).to.have.all.keys('remove'); - } + }, }); }); - it('of a replace operation should be possible', function () { + it('of a replace operation should be possible', function() { // Create two nodes with the same GUID var node1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var node2 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); @@ -913,21 +909,21 @@ describe('MapProperty', function () { node2._properties.stringProperty.value = 'testString2'; testChangeSetSquashing({ - pre: function (root) { + pre: function(root) { root._properties.map.insert('node1', node1); }, callbacks: [ removeFirstNodeInRoot, - function (root) { + function(root) { root._properties.map.insert('node2', node2); - } + }, ], - post: function (changeset) { + post: function(changeset) { expect(changeset['map'].map).to.have.all.keys('remove', 'insert'); - } + }, }); }); - it('should work for nested collections', function () { + it('should work for nested collections', function() { var node = PropertyFactory.create('NodeProperty'); var testMap = PropertyFactory.create('map'); @@ -943,28 +939,28 @@ describe('MapProperty', function () { expect(CS.getSerializedChangeSet().insert['map'].map).to.have.all.keys('insert'); expect(CS.getSerializedChangeSet().insert['map'].map.insert['test']).to.equal(false); }); - it('should work for a remove in a primitive map that contains another item', function () { + it('should work for a remove in a primitive map that contains another item', function() { var cs1 = { modify: { 'map': { testMap: { insert: { - test1: 'Hello' - } - } - } - } + test1: 'Hello', + }, + }, + }, + }, }; var cs2 = { modify: { 'map': { testMap: { remove: { - test2: 'Goodbye' - } - } - } - } + test2: 'Goodbye', + }, + }, + }, + }, }; var combined = new ChangeSet(); combined.applyChangeSet(cs1); @@ -974,20 +970,20 @@ describe('MapProperty', function () { 'map': { testMap: { insert: { - test1: 'Hello' + test1: 'Hello', }, remove: { - test2: 'Goodbye' - } - } - } - } + test2: 'Goodbye', + }, + }, + }, + }, }); }); - it('should work for maps in arrays', function () { + it('should work for maps in arrays', function() { testChangeSetSquashing({ callbacks: [ - function (root) { + function(root) { var arrayNode = PropertyFactory.create('array'); arrayNode.push(PropertyFactory.create('NodeProperty')); @@ -997,18 +993,18 @@ describe('MapProperty', function () { root._properties.map.insert('array', arrayNode); }, - function (root) { + function(root) { root.resolvePath('map[array][0].boolMap').set('test', true); }], - post: function (changeset) { + post: function(changeset) { expect(changeset['map'].map.insert['array'].array.insert['0'][1]['0'] .insert['map'].boolMap).to.have.all.keys('insert'); - } + }, }); }); }); - describe('Rebasing', function () { - var testRebasing = function (in_options) { + describe('Rebasing', function() { + var testRebasing = function(in_options) { // Prepare the initial state var baseProperty1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); if (in_options.prepare) { @@ -1067,162 +1063,162 @@ describe('MapProperty', function () { } }; - it('with a NOP should be possible', function () { + it('with a NOP should be possible', function() { testRebasing({ op2: insertUniqueNodeInRoot(), - compareToSequential: true + compareToSequential: true, }); }); - it('with independent inserts should be possible', function () { + it('with independent inserts should be possible', function() { testRebasing({ op1: insertUniqueNodeInRoot(), op2: insertUniqueNodeInRoot(), - compareToSequential: true + compareToSequential: true, }); }); - it('with independent removes should be possible', function () { + it('with independent removes should be possible', function() { var node1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var node2 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.map.insert('node1', node1); root._properties.map.insert('node2', node2); }, - op1: function (root) { + op1: function(root) { root._properties.map.remove('node1'); }, - op2: function (root) { + op2: function(root) { root._properties.map.remove('node2'); }, - compareToSequential: true + compareToSequential: true, }); }); - it('with a modify and a remove should possible', function () { + it('with a modify and a remove should possible', function() { var node1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.map.insert('node1', node1); }, op1: modifyLeaf, op2: removeFirstNodeInRoot, - compareToSequential: true + compareToSequential: true, }); }); - it('with a remove and a modify should possible', function () { + it('with a remove and a modify should possible', function() { var node1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.map.insert('node1', node1); }, op1: removeFirstNodeInRoot, op2: modifyLeaf, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFIED_AFTER_REMOVE); expect(conflicts[0].path).to.be.equal('map[node1]'); expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; - } + }, }); }); - it('reported conflicts should be escaped', function () { + it('reported conflicts should be escaped', function() { var node1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.map.insert('"node"', node1); }, op1: removeFirstNodeInRoot, op2: modifyLeaf, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFIED_AFTER_REMOVE); expect(conflicts[0].path).to.be.equal('map["\\"node\\""]'); expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; - } + }, }); }); - it('with two compatible removes should be possible', function () { + it('with two compatible removes should be possible', function() { var node1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.map.insert('node1', node1); }, - op1: function (root) { + op1: function(root) { root._properties.map.remove('node1'); }, - op2: function (root) { + op2: function(root) { root._properties.map.remove('node1'); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; - } + }, }); }); - it('with two indendent recursive modifies should be possible', function () { + it('with two indendent recursive modifies should be possible', function() { var node1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.map.insert('node1', node1); }, - op1: function (root) { + op1: function(root) { root._properties.map.getAsArray()[0]._properties.stringProperty.value = 'a'; }, - op2: function (root) { + op2: function(root) { root._properties.map.getAsArray()[0]._properties.stringProperty2.value = 'a'; }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.be.empty; - } + }, }); }); - it('with two conflicting recursive modifies should be possible and report a conflict', function () { + it('with two conflicting recursive modifies should be possible and report a conflict', function() { var node1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.map.insert('node1', node1); }, - op1: function (root) { + op1: function(root) { root._properties.map.getAsArray()[0]._properties.stringProperty.value = 'a'; }, - op2: function (root) { + op2: function(root) { root._properties.map.getAsArray()[0]._properties.stringProperty.value = 'a'; }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('map[node1].stringProperty'); - } + }, }); }); - it('with modify followed by remove+insert should work', function () { + it('with modify followed by remove+insert should work', function() { var node1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.map.insert('node1', node1); }, op1: modifyLeaf, - op2: function (root) { + op2: function(root) { root._properties.map.remove('node1'); var node2 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); @@ -1230,23 +1226,23 @@ describe('MapProperty', function () { root._properties.map.insert('node1', node2); }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.REMOVE_AFTER_MODIFY); expect(conflicts[0].path).to.be.equal('map[node1]'); expect(changeSet['map'].map).to.have.all.keys('remove', 'insert'); - } + }, }); }); - it('with remove+insert followed by modify should report conflict', function () { + it('with remove+insert followed by modify should report conflict', function() { var node1 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.map.insert('node1', node1); }, - op1: function (root) { + op1: function(root) { root._properties.map.remove('node1'); var node2 = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); @@ -1255,60 +1251,59 @@ describe('MapProperty', function () { }, op2: modifyLeaf, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFICATION_AFTER_REMOVE_INSERT); expect(conflicts[0].path).to.be.equal('map[node1]'); - } + }, }); }); - it('with remove+insert followed by remove+insert should report conflict', function () { + it('with remove+insert followed by remove+insert should report conflict', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.map.insert('node', PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0')); }, - op1: function (root) { + op1: function(root) { root._properties.map.set('node', PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0')); }, - op2: function (root) { + op2: function(root) { root._properties.map.set('node', PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0')); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('map[node]'); - } + }, }); }); - it('with conflicting inserts should report conflict', function () { - + it('with conflicting inserts should report conflict', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { }, - op1: function (root) { + op1: function(root) { var node = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); root._properties.map.insert('node', node); }, - op2: function (root) { + op2: function(root) { var node = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); root._properties.map.insert('node', node); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.INSERTED_ENTRY_WITH_SAME_KEY); expect(conflicts[0].path).to.be.equal('map[node]'); - } + }, }); }); - it('should report conflicts for nested collections', function () { + it('should report conflicts for nested collections', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { var node = PropertyFactory.create('NodeProperty'); var testMap = PropertyFactory.create('map'); testMap.set('test', false); @@ -1316,18 +1311,18 @@ describe('MapProperty', function () { root._properties.map.insert('node', node); }, - op1: function (root) { + op1: function(root) { root._properties.map.get('node')._properties.boolMap.set('test', true); }, - op2: function (root) { + op2: function(root) { root._properties.map.get('node')._properties.boolMap.set('test', true); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('map[node].boolMap[test]'); - } + }, }); }); }); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/namedNodeProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/namedNodeProperty.spec.js index 7bc96a91ff9a..4d6ccd75bdb0 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/namedNodeProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/namedNodeProperty.spec.js @@ -3,36 +3,35 @@ * Licensed under the MIT License. */ /* globals assert */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /** * @fileoverview In this file, we will test the map property * object described in /src/properties/namedNodeProperty.js */ -const { PropertyFactory } = require('../..'); -const { NamedNodeProperty } = require('../../properties/namedNodeProperty'); const { isGUID } = require('@fluid-experimental/property-common').GuidUtils; +const { PropertyFactory } = require('../..'); const { ContainerProperty } = require('../..'); +const { NamedNodeProperty } = require('../../properties/namedNodeProperty'); -describe('NamedNodeProperty', function () { - - before(function () { +describe('NamedNodeProperty', function() { + before(function() { // Register a templates var InheritingDirectlyTemplate = { typeid: 'autodesk.tests:InheritingDirectly-1.0.0', - inherits: ['NamedNodeProperty'] + inherits: ['NamedNodeProperty'], }; var InheritingSeparatelyTemplate = { typeid: 'autodesk.tests:InheritingSeparately-1.0.0', - inherits: ['NamedProperty', 'NodeProperty'] + inherits: ['NamedProperty', 'NodeProperty'], }; PropertyFactory._reregister(InheritingDirectlyTemplate); PropertyFactory._reregister(InheritingSeparatelyTemplate); }); - describe('Creation and ID', function () { - it('should be possible to create a NamedNodeProperty directly', function () { + describe('Creation and ID', function() { + it('should be possible to create a NamedNodeProperty directly', function() { const typeid = 'NamedNodeProperty'; var property = PropertyFactory.create(typeid); expect(property).to.be.an.instanceof(ContainerProperty); @@ -42,7 +41,7 @@ describe('NamedNodeProperty', function () { expect(PropertyFactory.inheritsFrom(typeid, 'NodeProperty')).to.be.true; }); - it('should be possible to create it via a template that inherits from NamedNodeProperty', function () { + it('should be possible to create it via a template that inherits from NamedNodeProperty', function() { const typeid = 'autodesk.tests:InheritingDirectly-1.0.0'; var property = PropertyFactory.create(typeid); expect(property).to.be.an.instanceof(ContainerProperty); @@ -52,7 +51,7 @@ describe('NamedNodeProperty', function () { expect(PropertyFactory.inheritsFrom(typeid, 'NodeProperty')).to.be.true; }); - it('should be possible to create a NamedNodeProperty by inheriting from Named and NodeProperty', function () { + it('should be possible to create a NamedNodeProperty by inheriting from Named and NodeProperty', function() { const typeid = 'autodesk.tests:InheritingSeparately-1.0.0'; const property = PropertyFactory.create(typeid); expect(property).to.be.an.instanceof(ContainerProperty); @@ -62,7 +61,7 @@ describe('NamedNodeProperty', function () { expect(PropertyFactory.inheritsFrom(typeid, 'NodeProperty')).to.be.true; }); - it('a GUID should be assigned on creation', function () { + it('a GUID should be assigned on creation', function() { var property = PropertyFactory.create('autodesk.tests:InheritingDirectly-1.0.0'); expect(property.getGuid()).not.to.be.not.empty; assert(isGUID(property.getGuid())); @@ -70,7 +69,7 @@ describe('NamedNodeProperty', function () { expect(property.getGuid()).to.equal(property.getId()); }); - it('the ID sould be overwritable', function () { + it('the ID sould be overwritable', function() { var property = PropertyFactory.create('autodesk.tests:InheritingDirectly-1.0.0'); property._setId('test'); expect(property.getId()).to.equal('test'); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/nodeProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/nodeProperty.spec.js index 0c0456df9f74..e8bc54a9fe94 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/nodeProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/nodeProperty.spec.js @@ -3,46 +3,46 @@ * Licensed under the MIT License. */ /* globals assert, sinon */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /** * @fileoverview In this file, we will test the NodeProperty * object described in properties/nodeProperty.js */ +const { ChangeSet } = require('@fluid-experimental/property-changeset'); +const { generateGUID } = require('@fluid-experimental/property-common').GuidUtils; +const { MSG } = require('@fluid-experimental/property-common').constants; +const _ = require('lodash'); const { PropertyFactory } = require('../..'); const { BaseProperty } = require('../..'); const { NodeProperty } = require('../../properties/nodeProperty'); const { MapProperty } = require('../../properties/mapProperty'); -const { ChangeSet } = require('@fluid-experimental/property-changeset'); -const _ = require('lodash'); -const { generateGUID } = require('@fluid-experimental/property-common').GuidUtils; -const { MSG } = require('@fluid-experimental/property-common').constants; -describe('NodeProperty', function () { +describe('NodeProperty', function() { var changeSetWithTwoMapEntries, changeSetWithTwoMapEntries_full, removalChangeSet; var myNode, mapNode1, mapNode2; - before(function () { + before(function() { // Register a template with a set property for the tests var MixedNodePropertyTemplate = { typeid: 'autodesk.tests:MixedNodeTestProperty-1.0.0', inherits: ['NodeProperty'], properties: [ { id: 'stringProperty', typeid: 'String' }, - { id: 'stringProperty2', typeid: 'String' } - ] + { id: 'stringProperty2', typeid: 'String' }, + ], }; var AnonymousTestPropertyTemplate = { typeid: 'autodesk.tests:AnonymousProperty-1.0.0', properties: [ - { id: 'stringProperty', typeid: 'String' } - ] + { id: 'stringProperty', typeid: 'String' }, + ], }; var MixedNamedNodePropertyTemplate = { typeid: 'autodesk.tests:MixedNamedNodeProperty-1.0.0', inherits: ['NodeProperty', 'NamedProperty'], properties: [ - { id: 'stringProperty', typeid: 'String' } - ] + { id: 'stringProperty', typeid: 'String' }, + ], }; var TestEnumTemplate = { typeid: 'autodesk.core:UnitsEnum-1.0.0', @@ -51,8 +51,8 @@ describe('NodeProperty', function () { properties: [ { id: 'm', value: 1, annotation: { description: 'meter' } }, { id: 'cm', value: 2, annotation: { description: 'centimeter' } }, - { id: 'mm', value: 3, annotation: { description: 'millimeter' } } - ] + { id: 'mm', value: 3, annotation: { description: 'millimeter' } }, + ], }; PropertyFactory._reregister(TestEnumTemplate); @@ -70,8 +70,8 @@ describe('NodeProperty', function () { properties: [ { id: 'x', typeid: 'Float32' }, { id: 'y', typeid: 'Float32' }, - { id: 'z', typeid: 'Float32' } - ] + { id: 'z', typeid: 'Float32' }, + ], }; var Point2DTemplate = { @@ -80,13 +80,13 @@ describe('NodeProperty', function () { { id: 'position', properties: [ { id: 'x', typeid: 'Float32' }, - { id: 'y', typeid: 'Float32' } - ] + { id: 'y', typeid: 'Float32' }, + ], }, { id: 'normal', typeid: 'autodesk.test:vector3-1.0.0' }, { id: 'neighbours', typeid: 'autodesk.test:vector3-1.0.0', context: 'map' }, - { id: 'temperature', typeid: 'Float32' } - ] + { id: 'temperature', typeid: 'Float32' }, + ], }; var SceneObjectTemplate = { @@ -94,8 +94,8 @@ describe('NodeProperty', function () { typeid: 'autodesk.test:SceneObject-1.0.0', properties: [ { id: 'name', typeid: 'String' }, - { id: 'revitId', typeid: 'String' } - ] + { id: 'revitId', typeid: 'String' }, + ], }; var nestedNodeProperty = { @@ -103,17 +103,17 @@ describe('NodeProperty', function () { properties: [ { id: 'nested', properties: [ - { id: 'property', typeid: 'NodeProperty' } - ] - } - ] + { id: 'property', typeid: 'NodeProperty' }, + ], + }, + ], }; var testArrayProperty = { typeid: 'autodesk.tests:test.array.property-1.0.0', properties: [ - { id: 'array', typeid: 'Float32', context: 'array' } - ] + { id: 'array', typeid: 'Float32', context: 'array' }, + ], }; PropertyFactory._reregister(Vec3Template); @@ -125,12 +125,12 @@ describe('NodeProperty', function () { // Helper functions for the test cases var keyCounter = 0; - var resetKeyCounter = function () { + var resetKeyCounter = function() { keyCounter = 0; }; // Inserts a node with the given guid (a new one is generated when undefined) - var insertNodeInRootWithKeyAndGuid = function (key, guid, root) { + var insertNodeInRootWithKeyAndGuid = function(key, guid, root) { var node = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); if (key === undefined) { key = 'node' + keyCounter++; @@ -140,18 +140,18 @@ describe('NodeProperty', function () { }; // Inserts a new node in the root - var insertNodeInRoot = function (root) { + var insertNodeInRoot = function(root) { insertNodeInRootWithKeyAndGuid(undefined, undefined, root); }; // Returns a functor that will insert a node with a constant GUID - var insertUniqueNodeInRoot = function () { + var insertUniqueNodeInRoot = function() { var key = 'node' + keyCounter++; return insertNodeInRootWithKeyAndGuid.bind(undefined, key, generateGUID()); }; // Inserts a new node as leaf - var insertNodeAsLeaf = function (root) { + var insertNodeAsLeaf = function(root) { var leaf = root; while (leaf.getDynamicIds().length > 0) { leaf = _.values(leaf._getDynamicChildrenReadOnly())[0]; @@ -162,13 +162,13 @@ describe('NodeProperty', function () { }; // Removes the first node from the root - var removeFirstNodeInRoot = function (root) { + var removeFirstNodeInRoot = function(root) { var firstKey = root.getDynamicIds()[0]; root.remove(firstKey); }; // Modifies the leaf node - var modifyLeaf = function (root) { + var modifyLeaf = function(root) { var leaf = root; while (leaf.getDynamicIds().length > 0) { leaf = _.values(leaf._getDynamicChildrenReadOnly())[0]; @@ -176,15 +176,13 @@ describe('NodeProperty', function () { leaf._properties.stringProperty.value = leaf._properties.stringProperty.value + '+'; }; - - describe('Testing creation, assignment and serialization', function () { - - it('should be empty at the beginning', function () { + describe('Testing creation, assignment and serialization', function() { + it('should be empty at the beginning', function() { expect(myNode.getIds()).to.be.empty; expect(myNode.serialize({ 'dirtyOnly': true })).to.be.empty; }); - it('should be possible to insert into the map', function () { + it('should be possible to insert into the map', function() { // Test insertion of the first node myNode.insert('node1', mapNode1); expect(myNode.has('node1')).to.be.ok; @@ -216,25 +214,25 @@ describe('NodeProperty', function () { expect(changeSetWithTwoMapEntries).to.deep.equal(changeSetWithTwoMapEntries_full); }); - it('should fail when trying to insert with empty id', function () { + it('should fail when trying to insert with empty id', function() { var myNode1 = PropertyFactory.create('NodeProperty'); var mapNode3 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); expect(() => myNode1.insert('', mapNode3)).to.throw(MSG.ID_SHOULD_NOT_BE_EMPTY_STRING); }); - it('should fail when trying to insert in itself', function () { + it('should fail when trying to insert in itself', function() { var myNode1 = PropertyFactory.create('NodeProperty'); expect(() => myNode1.insert('a', myNode1)).to.throw(MSG.INSERTED_IN_OWN_CHILDREN); }); - it('should fail when trying to insert in child', function () { + it('should fail when trying to insert in child', function() { var myNodeParent = PropertyFactory.create('NodeProperty'); var myNodeChild = PropertyFactory.create('NodeProperty'); myNodeParent.insert('a', myNodeChild); expect(() => myNodeChild.insert('a', myNodeParent)).to.throw(MSG.INSERTED_IN_OWN_CHILDREN); }); - it('should fail when trying to insert in grand-child', function () { + it('should fail when trying to insert in grand-child', function() { var myNodeParent = PropertyFactory.create('NodeProperty'); var myNodeChild = PropertyFactory.create('NodeProperty'); var myNodeGrandChild = PropertyFactory.create('NodeProperty'); @@ -243,7 +241,7 @@ describe('NodeProperty', function () { expect(() => myNodeGrandChild.insert('a', myNodeParent)).to.throw(MSG.INSERTED_IN_OWN_CHILDREN); }); - it('.remove should return the property removed', function () { + it('.remove should return the property removed', function() { var myNode1 = PropertyFactory.create('NodeProperty'); var mapNode3 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); var mapNode4 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); @@ -254,7 +252,7 @@ describe('NodeProperty', function () { expect(myNode1.getIds()).to.be.empty; }); - it('.clear should remove all nodes', function () { + it('.clear should remove all nodes', function() { var myNode1 = PropertyFactory.create('NodeProperty'); var mapNode3 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); var mapNode4 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); @@ -264,7 +262,7 @@ describe('NodeProperty', function () { expect(myNode1.getIds()).to.be.empty; }); - it('.getValues should work', function () { + it('.getValues should work', function() { var myNode1 = PropertyFactory.create('NodeProperty'); var mapNode3 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); var mapNode4 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); @@ -272,22 +270,22 @@ describe('NodeProperty', function () { myNode1.insert('node2', mapNode4); expect(myNode1.getValues()).to.deep.equal({ node1: { stringProperty: '', stringProperty2: '' }, - node2: { stringProperty: '', stringProperty2: '' } + node2: { stringProperty: '', stringProperty2: '' }, }); }); - it('getValues should work with nested arrays', function () { + it('getValues should work with nested arrays', function() { var myNode1 = PropertyFactory.create('NodeProperty'); var myArray = PropertyFactory.create('autodesk.tests:test.array.property-1.0.0'); myNode1.insert('array1', myArray); myNode1.get('array1').get('array').insertRange(0, [1, 2, 3]); expect(myNode1.getIds()).to.deep.equal(['array1']); expect(myNode1.getValues()).to.deep.equal({ - array1: { array: [1, 2, 3] } + array1: { array: [1, 2, 3] }, }); }); - it.skip('@bugfix getValues should work with circular references', function () { + it.skip('@bugfix getValues should work with circular references', function() { var myNode1 = PropertyFactory.create('NodeProperty'); var myRef1 = PropertyFactory.create('Reference', 'single', '/ref2'); var myRef2 = PropertyFactory.create('Reference', 'single', '/ref1'); @@ -297,51 +295,50 @@ describe('NodeProperty', function () { expect(myNode1.getIds()).to.deep.equal(['ref1', 'ref2']); expect(myNode1.getValues()).to.deep.equal({ 'ref1': '/ref2', - 'ref2': '/ref1' + 'ref2': '/ref1', }); }); - it('getValues should work with bad references', function () { + it('getValues should work with bad references', function() { var myNode1 = PropertyFactory.create('NodeProperty'); var myRef = PropertyFactory.create('Reference', 'single'); myNode1.insert('badref', myRef); myNode1.getValues(); expect(myNode1.getIds()).to.deep.equal(['badref']); expect(myNode1.getValues()).to.deep.equal({ - 'badref': undefined + 'badref': undefined, }); }); - it('Should track dirtiness', function () { + it('Should track dirtiness', function() { myNode.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY); expect(myNode.serialize({ 'dirtyOnly': true, 'includeRootTypeid': false, - 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY + 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY, })).to.be.empty; expect(myNode.serialize({ 'dirtyOnly': true, 'includeRootTypeid': false, - 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE + 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE, })).deep.equal(changeSetWithTwoMapEntries_full); expect(myNode.serialize({ 'dirtyOnly': false })).deep.equal(changeSetWithTwoMapEntries_full); }); - - it('Should handle removals correctly', function () { + it('Should handle removals correctly', function() { myNode.remove('node1'); expect(mapNode1.getParent()).to.be.undefined; myNode.remove('node2'); expect(myNode.serialize({ 'dirtyOnly': true, 'includeRootTypeid': false, - 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE + 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE, })).to.be.empty; expect(myNode.serialize({ 'dirtyOnly': false })).to.be.empty; removalChangeSet = myNode.serialize({ 'dirtyOnly': true, 'includeRootTypeid': false, - 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY + 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY, }); expect(removalChangeSet).to.have.all.keys(['remove']); expect(removalChangeSet.remove).to.have.length(2); @@ -349,7 +346,7 @@ describe('NodeProperty', function () { expect(removalChangeSet.remove).to.contain('node2'); }); - it('Should support deserialization', function () { + it('Should support deserialization', function() { var deserializedNode = PropertyFactory.create('NodeProperty'); var deserializedChanges1 = deserializedNode.deserialize(changeSetWithTwoMapEntries); var CS4 = deserializedNode.serialize({ 'dirtyOnly': false }); @@ -363,7 +360,7 @@ describe('NodeProperty', function () { expect(deserializedChanges3).to.deep.equal(removalChangeSet); }); - it('should support deserialization for nested properties', function () { + it('should support deserialization for nested properties', function() { var P1 = PropertyFactory.create('autodesk.tests:nested.node.property-1.0.0'); var P2 = PropertyFactory.create('autodesk.tests:nested.node.property-1.0.0'); @@ -375,8 +372,7 @@ describe('NodeProperty', function () { expect(P2._properties.nested.property.testProperty.value).to.equal('testString'); }); - - it('Should track modifies', function () { + it('Should track modifies', function() { var modifyNode1 = PropertyFactory.create('NodeProperty'); var modifyNode2 = PropertyFactory.create('NodeProperty'); @@ -393,7 +389,7 @@ describe('NodeProperty', function () { .to.deep.equal(modifyNode1.serialize({ 'dirtyOnly': false })); }); - it('Should support hierarchical properties', function () { + it('Should support hierarchical properties', function() { var node1 = PropertyFactory.create('NodeProperty'); var node2 = PropertyFactory.create('NodeProperty'); var node3 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); @@ -426,7 +422,7 @@ describe('NodeProperty', function () { expect(child2._properties.stringProperty.value).to.equal('test2'); }); - it('should be possible to use anonymous properties', function () { + it('should be possible to use anonymous properties', function() { var rootNode = PropertyFactory.create('NodeProperty'); var rootNode2 = PropertyFactory.create('NodeProperty'); var node1 = PropertyFactory.create('autodesk.tests:AnonymousProperty-1.0.0'); @@ -449,17 +445,17 @@ describe('NodeProperty', function () { expect(rootNode2.serialize({ 'dirtyOnly': false })).to.be.deep.equal(rootNode.serialize({ 'dirtyOnly': false })); }); - it('inserting the same key twice should throw an exception', function () { + it('inserting the same key twice should throw an exception', function() { var rootNode = PropertyFactory.create('NodeProperty'); var node1 = PropertyFactory.create('NodeProperty'); var node2 = PropertyFactory.create('NodeProperty'); rootNode.insert('node1', node1); - expect(function () { + expect(function() { rootNode.insert('node1', node2); }).to.throw(); }); - it('Should work to create a MixedNodeTemplate', function () { + it('Should work to create a MixedNodeTemplate', function() { var mixedNode = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); mixedNode.insert('dynamicFloat', PropertyFactory.create('Float32')); mixedNode.insert('dynamicString', PropertyFactory.create('String')); @@ -472,16 +468,16 @@ describe('NodeProperty', function () { expect(mixedNode.serialize({ 'dirtyOnly': false })).to.deep.equal({ String: { stringProperty: 'string1', - stringProperty2: 'string2' + stringProperty2: 'string2', }, insert: { String: { - dynamicString: 'dynamic2' + dynamicString: 'dynamic2', }, Float32: { - dynamicFloat: 11 - } - } + dynamicFloat: 11, + }, + }, }); mixedNode.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY | @@ -494,18 +490,18 @@ describe('NodeProperty', function () { expect(mixedNode.serialize({ 'dirtyOnly': true })).to.deep.equal({ String: { - stringProperty: 'modified1' + stringProperty: 'modified1', }, modify: { String: { - dynamicString: 'modified2' - } + dynamicString: 'modified2', + }, }, insert: { String: { - dynamicString2: 'dynamic3' - } - } + dynamicString2: 'dynamic3', + }, + }, }); // Pretty printing @@ -517,19 +513,19 @@ describe('NodeProperty', function () { ' dynamicString (String): "modified2"\n' + ' dynamicString2 (String): "dynamic3"\n'; var prettyStr = ''; - mixedNode.prettyPrint(function (str) { + mixedNode.prettyPrint(function(str) { prettyStr += str + '\n'; }); expect(prettyStr).to.equal(expectedPrettyStr); }); - it('inserting the same node twice should be a bug', function () { + it('inserting the same node twice should be a bug', function() { var rootNode = PropertyFactory.create('NodeProperty'); var node = PropertyFactory.create('NodeProperty'); // Try to insert the same node object under two keys rootNode.insert('node', node); - expect(function () { + expect(function() { rootNode.insert('node2', node); }).to.throw(); @@ -538,11 +534,11 @@ describe('NodeProperty', function () { rootNode.insert('node2', node); }); - it('should not allow adding two nodes with same id', function () { + it('should not allow adding two nodes with same id', function() { var NodeTemplate = { typeid: 'autodesk.tests:NodeTemplate-1.0.0', inherits: 'NodeProperty', - properties: [{ id: 'a', typeid: 'Float32' }] + properties: [{ id: 'a', typeid: 'Float32' }], }; PropertyFactory._reregister(NodeTemplate); @@ -550,12 +546,12 @@ describe('NodeProperty', function () { var node = PropertyFactory.create('autodesk.tests:NodeTemplate-1.0.0'); var child = PropertyFactory.create('String'); - expect(function () { + expect(function() { node.insert('a', child); }).to.throw(MSG.PROPERTY_ALREADY_EXISTS + 'a'); }); - it('Should correctly report whether it is a root', function () { + it('Should correctly report whether it is a root', function() { var root = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); var child = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); var stringProperty = child.resolvePath('stringProperty'); @@ -570,7 +566,7 @@ describe('NodeProperty', function () { expect(child.resolvePath(stringProperty.getRelativePath(child))).to.equal(stringProperty); }); - it('should correctly report changes when deserializing keys which contain 0', function () { + it('should correctly report changes when deserializing keys which contain 0', function() { var property = PropertyFactory.create('NodeProperty'); property.insert('test', PropertyFactory.create('Int32')); property._properties.test.value = 5; // Make sure, it is marked as modified @@ -585,7 +581,7 @@ describe('NodeProperty', function () { }); }); - describe('squashing', function () { + describe('squashing', function() { // // Helper function which takes a sequence of callbacks that are successively executed // and the changes applied by the callbacks are separately tracked and squashed in a @@ -594,7 +590,7 @@ describe('NodeProperty', function () { // Optionally, a a callback which controls the initial state before the squashing can // be given as first parameter // - var testChangeSetSquashing = function (in_options) { + var testChangeSetSquashing = function(in_options) { resetKeyCounter(); var testProperty = PropertyFactory.create('NodeProperty'); @@ -626,96 +622,96 @@ describe('NodeProperty', function () { expect(initialChangeset.getSerializedChangeSet()).to.deep.equal(testProperty.serialize({ 'dirtyOnly': false })); }; - it('should work for multiple independent inserts', function () { + it('should work for multiple independent inserts', function() { testChangeSetSquashing({ callbacks: [insertNodeInRoot, insertNodeInRoot, insertNodeInRoot] }); }); - it('should work for multiple hierarchical inserts', function () { + it('should work for multiple hierarchical inserts', function() { testChangeSetSquashing({ callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, insertNodeAsLeaf] }); }); - it('should work for inserts followed by removes', function () { + it('should work for inserts followed by removes', function() { testChangeSetSquashing({ callbacks: [insertNodeInRoot, insertNodeInRoot, removeFirstNodeInRoot, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('should work for a tree removal', function () { + it('should work for a tree removal', function() { testChangeSetSquashing({ callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, insertNodeAsLeaf, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('should work for modifies in a tree', function () { + it('should work for modifies in a tree', function() { testChangeSetSquashing({ - callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, insertNodeAsLeaf, modifyLeaf, modifyLeaf] + callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, insertNodeAsLeaf, modifyLeaf, modifyLeaf], }); }); - it('should work for modifies of a primitive type', function () { + it('should work for modifies of a primitive type', function() { testChangeSetSquashing({ callbacks: [ - function (root) { + function(root) { var newStringNode = PropertyFactory.create('String'); newStringNode.value = 'initial value'; root.insert('stringProp', newStringNode); }, - function (root) { + function(root) { root.get('stringProp').value = 'new value'; - } - ] + }, + ], }); }); - it('an insert, modify and a remove should give an empty changeset', function () { + it('an insert, modify and a remove should give an empty changeset', function() { testChangeSetSquashing({ callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, modifyLeaf, modifyLeaf, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('work for modifies after an already existing insert', function () { + it('work for modifies after an already existing insert', function() { testChangeSetSquashing({ pre: insertNodeInRoot, - callbacks: [modifyLeaf, modifyLeaf] + callbacks: [modifyLeaf, modifyLeaf], }); }); - it('of modify and remove after an already existing insert should work', function () { + it('of modify and remove after an already existing insert should work', function() { testChangeSetSquashing({ pre: insertNodeInRoot, callbacks: [modifyLeaf, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.have.all.keys('remove'); - } + }, }); }); - it('of a replace operation should be possible', function () { + it('of a replace operation should be possible', function() { // Create two nodes var node1 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); var node2 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); node2._properties.stringProperty.value = 'testString2'; testChangeSetSquashing({ - pre: function (root) { + pre: function(root) { root.insert('node1', node1); }, callbacks: [ removeFirstNodeInRoot, - function (root) { + function(root) { root.insert('node1', node2); - } + }, ], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.have.all.keys('remove', 'insert'); - } + }, }); }); }); - describe('Rebasing', function () { - var testRebasing = function (in_options) { + describe('Rebasing', function() { + var testRebasing = function(in_options) { // Prepare the initial state var baseProperty1 = PropertyFactory.create('NodeProperty'); if (in_options.prepare) { @@ -773,358 +769,357 @@ describe('NodeProperty', function () { } }; - it('with a NOP should be possible', function () { + it('with a NOP should be possible', function() { testRebasing({ op2: insertUniqueNodeInRoot(), - compareToSequential: true + compareToSequential: true, }); }); - it('with independent inserts should be possible', function () { + it('with independent inserts should be possible', function() { testRebasing({ op1: insertUniqueNodeInRoot(), op2: insertUniqueNodeInRoot(), - compareToSequential: true + compareToSequential: true, }); }); - it('with independent removes should be possible', function () { + it('with independent removes should be possible', function() { var node1 = PropertyFactory.create('NodeProperty'); var node2 = PropertyFactory.create('NodeProperty'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root.insert('node1', node1); root.insert('node2', node2); }, - op1: function (root) { + op1: function(root) { root.remove('node1'); }, - op2: function (root) { + op2: function(root) { root.remove('node2'); }, - compareToSequential: true + compareToSequential: true, }); }); - it('with a modify and a remove should possible', function () { + it('with a modify and a remove should possible', function() { var node1 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root.insert('node1', node1); }, op1: modifyLeaf, op2: removeFirstNodeInRoot, - compareToSequential: true + compareToSequential: true, }); }); - it('with a remove and a modify should possible', function () { + it('with a remove and a modify should possible', function() { var node1 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root.insert('node1', node1); }, op1: removeFirstNodeInRoot, op2: modifyLeaf, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFIED_AFTER_REMOVE); expect(conflicts[0].path).to.be.equal('node1'); expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; - } + }, }); }); - it('with two compatible removes should be possible', function () { + it('with two compatible removes should be possible', function() { var node1 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root.insert('node1', node1); }, - op1: function (root) { + op1: function(root) { root.remove('node1'); }, - op2: function (root) { + op2: function(root) { root.remove('node1'); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; - } + }, }); }); - it('with two indendent recursive modifies should be possible', function () { + it('with two indendent recursive modifies should be possible', function() { var node1 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root.insert('node1', node1); }, - op1: function (root) { + op1: function(root) { _.values(root._getDynamicChildrenReadOnly())[0]._properties.stringProperty.value = 'a'; }, - op2: function (root) { + op2: function(root) { _.values(root._getDynamicChildrenReadOnly())[0]._properties.stringProperty2.value = 'a'; }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.be.empty; - } + }, }); }); - it('with two conflicting recursive modifies should be possible and report a conflict', function () { + it('with two conflicting recursive modifies should be possible and report a conflict', function() { var node1 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root.insert('node1', node1); }, - op1: function (root) { + op1: function(root) { _.values(root._getDynamicChildrenReadOnly())[0]._properties.stringProperty.value = 'b'; }, - op2: function (root) { + op2: function(root) { _.values(root._getDynamicChildrenReadOnly())[0]._properties.stringProperty.value = 'a'; }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(changeSet.modify['autodesk.tests:MixedNodeTestProperty-1.0.0'] .node1.String.stringProperty).to.equal('a'); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('node1.stringProperty'); - } + }, }); }); - it('with modify followed by remove+insert should work', function () { + it('with modify followed by remove+insert should work', function() { var node1 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root.insert('node1', node1); }, op1: modifyLeaf, - op2: function (root) { + op2: function(root) { var node2 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); root.remove('node1'); root.insert('node1', node2); }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.REMOVE_AFTER_MODIFY); expect(conflicts[0].path).to.be.equal('node1'); expect(changeSet).to.have.all.keys('remove', 'insert'); - } + }, }); }); - it('with remove+insert followed by modify should report conflict', function () { + it('with remove+insert followed by modify should report conflict', function() { var node1 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root.insert('node1', node1); }, - op1: function (root) { + op1: function(root) { var node2 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); root.remove('node1'); root.insert('node1', node2); }, op2: modifyLeaf, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFICATION_AFTER_REMOVE_INSERT); expect(conflicts[0].path).to.be.equal('node1'); - } + }, }); }); - it('with remove+insert followed by remove+insert should report conflict', function () { + it('with remove+insert followed by remove+insert should report conflict', function() { var node = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root.insert('node', node); }, - op1: function (root) { + op1: function(root) { root.remove('node'); root.insert('node', PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0')); }, - op2: function (root) { + op2: function(root) { root.remove('node'); root.insert('node', PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0')); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('node'); - } + }, }); }); - it('with conflicting inserts should report conflict', function () { + it('with conflicting inserts should report conflict', function() { var node1 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); var node2 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { }, - op1: function (root) { + op1: function(root) { root.insert('node1', node1); }, - op2: function (root) { + op2: function(root) { root.insert('node1', node2); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.INSERTED_ENTRY_WITH_SAME_KEY); expect(conflicts[0].path).to.be.equal('node1'); - } + }, }); }); - it('with conflicting inserts of primitive types', function () { + it('with conflicting inserts of primitive types', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { }, - op1: function (root) { + op1: function(root) { var string1 = PropertyFactory.create('String'); string1.value = 'test1'; root.insert('entry', string1); }, - op2: function (root) { + op2: function(root) { var string2 = PropertyFactory.create('String'); string2.value = 'test2'; root.insert('entry', string2); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(changeSet).to.deep.equal({ modify: { String: { entry: { oldValue: 'test1', - value: 'test2' - } - } - } + value: 'test2', + }, + }, + }, }); expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('entry'); expect(conflicts[0].conflictingChange).to.be.equal('test2'); - } + }, }); }); // TODO: 'with conflicting inserts of primitive types' is identical to the below test. Why? - it('with conflicting recursive modifies of primitive types should be possible and report a conflict', function () { + it('with conflicting recursive modifies of primitive types should be possible and report a conflict', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { }, - op1: function (root) { + op1: function(root) { var string1 = PropertyFactory.create('String'); string1.value = 'test1'; root.insert('entry', string1); }, - op2: function (root) { + op2: function(root) { var string2 = PropertyFactory.create('String'); string2.value = 'test2'; root.insert('entry', string2); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(changeSet).to.deep.equal({ modify: { String: { entry: { oldValue: 'test1', - value: 'test2' - } - } - } + value: 'test2', + }, + }, + }, }); expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('entry'); expect(conflicts[0].conflictingChange).to.be.equal('test2'); - } + }, }); }); - it('with conflicting recursive modifies of enums should be possible and report a conflict', function () { + it('with conflicting recursive modifies of enums should be possible and report a conflict', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { }, - op1: function (root) { + op1: function(root) { var enum1 = PropertyFactory.create('autodesk.core:UnitsEnum-1.0.0'); enum1.value = 1; root.insert('entry', enum1); }, - op2: function (root) { + op2: function(root) { var enum2 = PropertyFactory.create('autodesk.core:UnitsEnum-1.0.0'); enum2.value = 2; root.insert('entry', enum2); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(changeSet).to.deep.equal({ modify: { 'enum': { entry: { oldValue: 1, - value: 2 - } - } - } + value: 2, + }, + }, + }, }); expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('entry'); expect(conflicts[0].conflictingChange).to.be.equal(2); - } + }, }); }); - - it('with conflicting inserts in a deep leaf should report a correct conflict', function () { + it('with conflicting inserts in a deep leaf should report a correct conflict', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { var node = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); root.insert('node', node); }, - op1: function (root) { + op1: function(root) { var node1 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); root.resolvePath('node').insert('node2', node1); }, - op2: function (root) { + op2: function(root) { var node2 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); root.resolvePath('node').insert('node2', node2); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.INSERTED_ENTRY_WITH_SAME_KEY); expect(conflicts[0].path).to.be.equal('node.node2'); - } + }, }); }); }); - describe('Compatibility with ChangeSets from spec', function () { + describe('Compatibility with ChangeSets from spec', function() { // These are the ChangeSets from the discussion minutes document // after some cleanup, mainly missing parameters were added in inserts and // syntax corrections. Additionally, the Vector3 was renamed to autodesk.test:vector3-1.0.0 to avoid @@ -1137,16 +1132,16 @@ describe('NodeProperty', function () { 'Float32': { 'position.x': 122, 'position.y': 122, - 'temperature': 10 + 'temperature': 10, }, 'autodesk.test:vector3-1.0.0': { 'normal': { Float32: { 'x': 1, 'y': 1, - 'z': 1 - } - } + 'z': 1, + }, + }, }, 'map': { 'neighbours': { @@ -1156,36 +1151,36 @@ describe('NodeProperty', function () { Float32: { 'x': 1, 'y': 1, - 'z': 1 - } - } - } - } - } - } + 'z': 1, + }, + }, + }, + }, + }, + }, }, 'd23kjda': { Float32: { 'position.x': 122, 'position.y': 122, - 'temperature': 11 + 'temperature': 11, }, 'autodesk.test:vector3-1.0.0': { 'normal': { Float32: { 'x': 1, 'y': 1, - 'z': 1 - } - } + 'z': 1, + }, + }, }, 'map': { - 'neighbours': {} - } - } + 'neighbours': {}, + }, + }, }, Float32: { - 'compression': 0 + 'compression': 0, }, 'map<>': { birds: { @@ -1195,16 +1190,16 @@ describe('NodeProperty', function () { Float32: { 'x': 1, 'y': 1, - 'z': 1 - } - } - } - } + 'z': 1, + }, + }, + }, + }, }, horses: {}, - forest: {} - } - } + forest: {}, + }, + }, }; var modifyChangeSet1 = { @@ -1213,18 +1208,18 @@ describe('NodeProperty', function () { 'myPoint': { 'Float32': { 'position.x': 11, - 'temperature': 31 + 'temperature': 31, }, 'autodesk.test:vector3-1.0.0': { 'normal': { 'Float32': { - 'x': 0.5 - } - } - } - } - } - } + 'x': 0.5, + }, + }, + }, + }, + }, + }, }; var modifyChangeSet2 = { @@ -1239,16 +1234,16 @@ describe('NodeProperty', function () { Float32: { 'x': 1, 'y': 1, - 'z': 1 - } - } - } - } - } - } - } - } - } + 'z': 1, + }, + }, + }, + }, + }, + }, + }, + }, + }, }; var modifyChangeSet3 = { @@ -1261,16 +1256,16 @@ describe('NodeProperty', function () { 'autodesk.test:vector3-1.0.0': { 'Point2': { Float32: { - 'x': 2 - } - } - } - } - } - } - } - } - } + 'x': 2, + }, + }, + }, + }, + }, + }, + }, + }, + }, }; var removePreparationChangeSet1 = { @@ -1279,11 +1274,11 @@ describe('NodeProperty', function () { 'dasdm23': { 'String': { 'revitId': '#23213', - 'name': 'Door' - } - } - } - } + 'name': 'Door', + }, + }, + }, + }, }; var removePreparationChangeSet2 = { @@ -1295,20 +1290,20 @@ describe('NodeProperty', function () { 'as2398d': { 'String': { 'revitId': '#2231', - 'name': 'Room' - } - } - } - } - } - } - } + 'name': 'Room', + }, + }, + }, + }, + }, + }, + }, }; var removeChangeSet1 = { remove: [ - 'dasdm23' - ] + 'dasdm23', + ], }; var removeChangeSet2 = { @@ -1316,14 +1311,14 @@ describe('NodeProperty', function () { 'autodesk.test:SceneObject-1.0.0': { 'dasdm23': { remove: [ - 'as2398d' - ] - } - } - } + 'as2398d', + ], + }, + }, + }, }; - it('should be possible to insert properties with the example from the spec', function () { + it('should be possible to insert properties with the example from the spec', function() { var rootProperty = PropertyFactory.create('NodeProperty'); rootProperty.applyChangeSet(insertChangeSet1); @@ -1363,7 +1358,7 @@ describe('NodeProperty', function () { expect(rootProperty.serialize({ 'dirtyOnly': true })).to.deep.equal(insertChangeSet1); }); - it('should be possible to use the first modify ChangeSet from the spec', function () { + it('should be possible to use the first modify ChangeSet from the spec', function() { // Prepare the initial state var rootProperty = PropertyFactory.create('NodeProperty'); rootProperty.applyChangeSet(insertChangeSet1); @@ -1382,7 +1377,7 @@ describe('NodeProperty', function () { expect(rootProperty.serialize({ 'dirtyOnly': true })).to.deep.equal(modifyChangeSet1); }); - it('should be possible to use the second modify ChangeSet from the spec', function () { + it('should be possible to use the second modify ChangeSet from the spec', function() { // Prepare the initial state var rootProperty = PropertyFactory.create('NodeProperty'); rootProperty.applyChangeSet(insertChangeSet1); @@ -1402,7 +1397,7 @@ describe('NodeProperty', function () { expect(rootProperty.serialize({ 'dirtyOnly': true })).to.deep.equal(modifyChangeSet2); }); - it('should be possible to use the third modify ChangeSet from the spec', function () { + it('should be possible to use the third modify ChangeSet from the spec', function() { // Prepare the initial state var rootProperty = PropertyFactory.create('NodeProperty'); rootProperty.applyChangeSet(insertChangeSet1); @@ -1421,7 +1416,7 @@ describe('NodeProperty', function () { expect(rootProperty.serialize({ 'dirtyOnly': true })).to.deep.equal(modifyChangeSet3); }); - it('should be possible to use the first remove ChangeSet from the spec', function () { + it('should be possible to use the first remove ChangeSet from the spec', function() { // Prepare the initial state var rootProperty = PropertyFactory.create('NodeProperty'); rootProperty.applyChangeSet(removePreparationChangeSet1); @@ -1440,7 +1435,7 @@ describe('NodeProperty', function () { expect(rootProperty.serialize({ 'dirtyOnly': true })).to.deep.equal(removeChangeSet1); }); - it('should be possible to use the first remove ChangeSet from the spec', function () { + it('should be possible to use the first remove ChangeSet from the spec', function() { // Prepare the initial state var rootProperty = PropertyFactory.create('NodeProperty'); rootProperty.applyChangeSet(removePreparationChangeSet1); @@ -1461,8 +1456,8 @@ describe('NodeProperty', function () { }); }); - describe('Make sure struct changes and path updates are signaled correctly', function () { - it('Should be possible to access dynamic nodes via propertis and paths', function () { + describe('Make sure struct changes and path updates are signaled correctly', function() { + it('Should be possible to access dynamic nodes via propertis and paths', function() { var root = PropertyFactory.create('NodeProperty'); var newRoot = PropertyFactory.create('NodeProperty'); @@ -1613,7 +1608,7 @@ describe('NodeProperty', function () { }); }); - it('should correctly clean templates inheriting from NamedNodeProperty', function () { + it('should correctly clean templates inheriting from NamedNodeProperty', function() { var property = PropertyFactory.create('autodesk.tests:MixedNamedNodeProperty-1.0.0'); var childProperty = property.get('stringProperty'); childProperty.value = 'changed'; @@ -1623,8 +1618,8 @@ describe('NodeProperty', function () { expect(childProperty.isDirty()).to.be.false; }); - describe('Make sure to have appropriate types for ids given to nodeProperty when inserting', function () { - it('should be possible for the id passed to be a string', function (done) { + describe('Make sure to have appropriate types for ids given to nodeProperty when inserting', function() { + it('should be possible for the id passed to be a string', function(done) { var node1 = PropertyFactory.create('NodeProperty'); var node2 = PropertyFactory.create('autodesk.tests:MixedNamedNodeProperty-1.0.0'); var node3 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); @@ -1637,7 +1632,7 @@ describe('NodeProperty', function () { done(); }); - it('should be possible for the id passed to be a number', function (done) { + it('should be possible for the id passed to be a number', function(done) { var node1 = PropertyFactory.create('NodeProperty'); var node2 = PropertyFactory.create('autodesk.tests:MixedNamedNodeProperty-1.0.0'); var node3 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); @@ -1650,7 +1645,7 @@ describe('NodeProperty', function () { done(); }); - it('should throw an error when the id passed is an object', function (done) { + it('should throw an error when the id passed is an object', function(done) { var node1 = PropertyFactory.create('NodeProperty'); var node2 = PropertyFactory.create('autodesk.tests:MixedNamedNodeProperty-1.0.0'); var node3 = PropertyFactory.create('autodesk.tests:MixedNodeTestProperty-1.0.0'); @@ -1665,26 +1660,26 @@ describe('NodeProperty', function () { }); }); - describe('_coveredByPaths', function () { + describe('_coveredByPaths', function() { this.timeout(500); let PathHelper, getPathCoverageSpy, paths, prop, propPath; - before(function () { + before(function() { PathHelper = require('@fluid-experimental/property-changeset').PathHelper; }); - beforeEach(function () { + beforeEach(function() { getPathCoverageSpy = sinon.spy(PathHelper, 'getPathCoverage'); }); - afterEach(function () { + afterEach(function() { PathHelper.getPathCoverage.restore(); }); - after(function () { + after(function() { }); - it('should succeed if property is included in a path 1', function () { + it('should succeed if property is included in a path 1', function() { paths = ['a.b']; prop = PropertyFactory.create('String'); propPath = 'a.b'; @@ -1693,7 +1688,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true; }); - it('should succeed if property is included in a path 2', function () { + it('should succeed if property is included in a path 2', function() { paths = ['a.b']; prop = PropertyFactory.create('Int32'); propPath = 'a.b.c'; @@ -1702,7 +1697,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true; }); - it('should succeed if property is a primitive collection included in a path', function () { + it('should succeed if property is a primitive collection included in a path', function() { paths = ['a.b']; prop = PropertyFactory.create('Int32', 'array'); propPath = 'a.b.c.d'; @@ -1711,7 +1706,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true; }); - it('should fail if property is not included in any path 1', function () { + it('should fail if property is not included in any path 1', function() { paths = ['a.b']; prop = PropertyFactory.create('Bool'); propPath = 'b'; @@ -1720,7 +1715,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true; }); - it('should fail if property is not included in any path 2', function () { + it('should fail if property is not included in any path 2', function() { paths = ['a.b']; prop = PropertyFactory.create('Float32'); propPath = 'b.f.g'; @@ -1729,7 +1724,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true; }); - it('should fail if property is not included in any path but have common root 1', function () { + it('should fail if property is not included in any path but have common root 1', function() { paths = ['a.b']; prop = PropertyFactory.create('String', 'map'); propPath = 'a.h'; @@ -1738,7 +1733,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true; }); - it('should fail if property is not included in any path but have common root 2', function () { + it('should fail if property is not included in any path but have common root 2', function() { paths = ['a.b']; prop = PropertyFactory.create('NodeProperty'); propPath = 'a.i.j'; @@ -1747,7 +1742,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true; }); - it('should succeed if path goes through a primitive property 1', function () { + it('should succeed if path goes through a primitive property 1', function() { paths = ['a.b.c', 'a.b.d', 'z']; prop = PropertyFactory.create('String'); propPath = 'a.b'; @@ -1756,7 +1751,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true; }); - it('should succeed if path goes through a primitive property 2', function () { + it('should succeed if path goes through a primitive property 2', function() { paths = ['a.b.c', 'a.b.d', 'z']; prop = PropertyFactory.create('Int32'); propPath = 'a.b'; @@ -1765,7 +1760,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true; }); - it('should succeed if path goes through a primitive collection property 1', function () { + it('should succeed if path goes through a primitive collection property 1', function() { paths = ['a.b.c', 'z', 'a.b.d']; prop = PropertyFactory.create('Int32', 'map'); propPath = 'a.b'; @@ -1774,7 +1769,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true; }); - it('should succeed if path goes through a primitive collection property 2', function () { + it('should succeed if path goes through a primitive collection property 2', function() { paths = ['z', 'a.b.c', 'a.b.d']; prop = PropertyFactory.create('String', 'array'); propPath = 'a.b'; @@ -1783,7 +1778,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true; }); - it('should succeed if path goes through a non-primitive collection property 1', function () { + it('should succeed if path goes through a non-primitive collection property 1', function() { paths = ['a.b.c', 'z', 'a.b.d']; prop = PropertyFactory.create('NodeProperty', 'map'); propPath = 'a.b'; @@ -1792,7 +1787,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true; }); - it('should succeed if path goes through a non-primitive collection property 2', function () { + it('should succeed if path goes through a non-primitive collection property 2', function() { paths = ['z', 'a.b.c', 'a.b.d']; prop = PropertyFactory.create('NamedProperty', 'set'); propPath = 'a.b'; @@ -1801,7 +1796,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true; }); - it('should succeed if property is included in multiple paths 1', function () { + it('should succeed if property is included in multiple paths 1', function() { paths = ['a.b.c', 'a.b.d', 'z']; prop = PropertyFactory.create('NodeProperty'); prop.insert('c', PropertyFactory.create('String')); @@ -1814,7 +1809,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith('a.b.d', ['a.b.c', 'a.b.d'])).to.be.true; }); - it('should succeed if property is included in multiple paths 2', function () { + it('should succeed if property is included in multiple paths 2', function() { paths = ['a.b.c', 'z', 'a.b.d']; prop = PropertyFactory.create('NodeProperty'); let c = PropertyFactory.create('NodeProperty'); @@ -1833,7 +1828,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith('a.b.d', ['a.b.c', 'a.b.d'])).to.be.true; }); - it('should succeed if property is included in multiple paths 3', function () { + it('should succeed if property is included in multiple paths 3', function() { paths = ['a.b.c.f', 'a.b.c', 'a.b.d.h', 'a.b.d.i', 'a.z']; prop = PropertyFactory.create('NodeProperty'); let c = PropertyFactory.create('NodeProperty'); @@ -1854,7 +1849,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith('a.b.d.i', ['a.b.d.h', 'a.b.d.i'])).to.be.true; }); - it('should succeed if property is included in multiple paths 4', function () { + it('should succeed if property is included in multiple paths 4', function() { paths = ['a.b.c.f', 'a.b.c', 'a.b.d.h', 'a.b.d.i', 'a.z']; prop = PropertyFactory.create('NodeProperty'); let b = PropertyFactory.create('NodeProperty'); @@ -1878,7 +1873,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith('a.b.d.i', ['a.b.d.h', 'a.b.d.i'])).to.be.true; }); - it('should succeed if property is included in multiple paths through map 1', function () { + it('should succeed if property is included in multiple paths through map 1', function() { paths = ['a.b.c', 'a.b.d.z', 'z']; prop = PropertyFactory.create('String', 'map'); prop.insert('c', 'c'); @@ -1891,7 +1886,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith('a.b.d', ['a.b.c', 'a.b.d.z'])).to.be.true; }); - it('should succeed if property is included in multiple paths through map 2', function () { + it('should succeed if property is included in multiple paths through map 2', function() { paths = ['a.b.c.f', 'a.b.c', 'a.b.d.h', 'a.b.d.i', 'a.z']; prop = PropertyFactory.create('NodeProperty'); let c = PropertyFactory.create('NodeProperty'); @@ -1912,7 +1907,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith('a.b.d.i', ['a.b.d.h', 'a.b.d.i'])).to.be.true; }); - it('should fail if property is not completely included in multiple paths 1', function () { + it('should fail if property is not completely included in multiple paths 1', function() { paths = ['a.b.c', 'a.b.d', 'z']; prop = PropertyFactory.create('NodeProperty'); prop.insert('c', PropertyFactory.create('String')); @@ -1923,7 +1918,7 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true; }); - it('should fail if property is not completely included in multiple paths 2', function () { + it('should fail if property is not completely included in multiple paths 2', function() { paths = ['z', 'a.b.d', 'a.b.c']; prop = PropertyFactory.create('NodeProperty'); prop.insert('e', PropertyFactory.create('String')); @@ -1933,6 +1928,5 @@ describe('NodeProperty', function () { expect(getPathCoverageSpy.callCount).to.be.above(1); expect(getPathCoverageSpy.calledWith(propPath, paths)).to.be.true; }); - }); }); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/referenceProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/referenceProperty.spec.js index bf48465b29ce..b0433b351473 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/referenceProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/referenceProperty.spec.js @@ -10,19 +10,18 @@ * /src/properties/referenceArrayProperty.js, * /src/properties/referenceMapProperty.js */ +const { ChangeSet } = require('@fluid-experimental/property-changeset'); +const { MSG } = require('@fluid-experimental/property-common').constants; +const { BaseProperty } = require('../..'); const { PropertyFactory } = require('../..'); const { ReferenceProperty } = require('../../properties/referenceProperty'); const { ReferenceMapProperty } = require('../../properties/referenceMapProperty'); const { ReferenceArrayProperty } = require('../../properties/referenceArrayProperty'); -const { ChangeSet } = require('@fluid-experimental/property-changeset'); -const { BaseProperty } = require('../..'); -const { MSG } = require('@fluid-experimental/property-common').constants; -describe('Reference Properties', function () { +describe('Reference Properties', function() { var dereferenceToken; - before(function () { - + before(function() { dereferenceToken = BaseProperty.PATH_TOKENS.REF; // A template that contains all types of reference properties @@ -34,15 +33,15 @@ describe('Reference Properties', function () { { id: 'refArray', typeid: 'Reference', context: 'array' }, { id: 'refArray_anon', typeid: 'Reference', context: 'array' }, { id: 'refMap', typeid: 'Reference', context: 'map' }, - { id: 'refMap_anon', typeid: 'Reference', context: 'map' } - ] + { id: 'refMap_anon', typeid: 'Reference', context: 'map' }, + ], }; PropertyFactory._reregister(referencePropertyTestTemplate); }); - describe('ReferenceProperty', function () { - it('should be possible to create', function () { + describe('ReferenceProperty', function() { + it('should be possible to create', function() { // Test creation of an anonymous reference var reference = PropertyFactory.create('Reference'); expect(reference).to.be.instanceof(ReferenceProperty); @@ -61,7 +60,7 @@ describe('Reference Properties', function () { expect(prop._properties.ref.getReferenceTargetTypeId()).to.equal('NodeProperty'); }); - it('empty reference should resolve to undefined', function () { + it('empty reference should resolve to undefined', function() { var reference = PropertyFactory.create('Reference'); // It should work with the default value @@ -74,7 +73,7 @@ describe('Reference Properties', function () { expect(reference.get()).to.be.undefined; }); - it('setting a referenced member to undefined should turn it into an empty string', function () { + it('setting a referenced member to undefined should turn it into an empty string', function() { var reference = PropertyFactory.create('Reference'); // First set it to something else than an empty reference @@ -87,12 +86,12 @@ describe('Reference Properties', function () { expect(reference.ref).to.be.undefined; }); - it('setting a reference to a non absolute path should not throw', function () { + it('setting a reference to a non absolute path should not throw', function() { var reference = PropertyFactory.create('Reference'); - expect(function () { reference.value = 'test'; }).to.not.throw(); + expect(function() { reference.value = 'test'; }).to.not.throw(); }); - it('.get should work to resolve the referenced property', function () { + it('.get should work to resolve the referenced property', function() { var root = PropertyFactory.create('NodeProperty'); var reference = PropertyFactory.create('Reference'); var target = PropertyFactory.create('String'); @@ -110,28 +109,28 @@ describe('Reference Properties', function () { expect(root.get('reference', 'string')).to.equal(target); expect(root.get('reference', { - referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.ALWAYS + referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.ALWAYS, })).to.equal(target); expect(root.get('reference', { - referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER + referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER, })).to.equal(reference); expect(root.get('reference', { - referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NO_LEAFS + referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NO_LEAFS, })).to.equal(reference); reference.set(node); expect(root.get(['reference', 'target'], { - referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.ALWAYS + referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.ALWAYS, })).to.equal(nodeTarget); expect(root.get(['reference', 'target'], { - referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER + referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER, })).to.equal(undefined); expect(root.get(['reference', 'target'], { - referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NO_LEAFS + referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NO_LEAFS, })).to.equal(nodeTarget); }); - it('.get should work with different types of input', function () { + it('.get should work with different types of input', function() { var root = PropertyFactory.create('NodeProperty'); var reference = PropertyFactory.create('Reference'); var node = PropertyFactory.create('NodeProperty'); @@ -147,7 +146,7 @@ describe('Reference Properties', function () { expect(reference.get([])).to.equal(reference); }); - it('.get should return undefined with invalid reference', function () { + it('.get should return undefined with invalid reference', function() { var root = PropertyFactory.create('NodeProperty'); var reference = PropertyFactory.create('Reference'); var node = PropertyFactory.create('NodeProperty'); @@ -171,7 +170,7 @@ describe('Reference Properties', function () { expect(reference.get(['target'])).to.undefined; }); - it('.resolvePath should work to resolve the referenced property', function () { + it('.resolvePath should work to resolve the referenced property', function() { var root = PropertyFactory.create('NodeProperty'); var reference = PropertyFactory.create('Reference'); var target = PropertyFactory.create('String'); @@ -182,38 +181,37 @@ describe('Reference Properties', function () { root.insert('node', node); node.insert('target', nodeTarget); - reference.set(target); expect(root.resolvePath('reference')).to.equal(target); expect(root.resolvePath('reference', { - referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.ALWAYS + referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.ALWAYS, })).to.equal(target); expect(root.resolvePath('reference', { - referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER + referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER, })).to.equal(reference); expect(root.resolvePath('reference', { - referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NO_LEAFS + referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NO_LEAFS, })).to.equal(reference); reference.set(node); expect(root.resolvePath('reference.target', { - referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.ALWAYS + referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.ALWAYS, })).to.equal(nodeTarget); expect(root.resolvePath('reference.target', { - referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER + referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER, })).to.equal(undefined); expect(root.resolvePath('reference.target', { - referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NO_LEAFS + referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NO_LEAFS, })).to.equal(nodeTarget); }); - describe('Reference resolution', function () { + describe('Reference resolution', function() { var root, target, reference, reference2, relativeReference, relativeReference2; var nodeTarget, nestedChild, nodeTarget2, nestedChild2; var mapTarget, nestedMapChild; var arrayTarget, nestedArrayChild; - beforeEach(function () { + beforeEach(function() { root = PropertyFactory.create('NodeProperty'); nodeTarget = PropertyFactory.create('NodeProperty'); @@ -252,14 +250,14 @@ describe('Reference Properties', function () { target.value = 'test'; }); - it('should allow resolving references', function () { + it('should allow resolving references', function() { reference.value = '/target'; expect(reference.ref).to.equal(target); expect(reference.ref.value).to.equal('test'); }); - it('should support setting via set', function () { + it('should support setting via set', function() { reference.set(target); expect(reference.ref).to.equal(target); @@ -267,35 +265,35 @@ describe('Reference Properties', function () { expect(reference.value).to.equal('/target'); }); - it('set with a Property should work', function () { + it('set with a Property should work', function() { reference.set(nestedChild); expect(reference.getValue()).to.equal('/nodeTarget.nested'); }); - it('set with a path should work', function () { + it('set with a path should work', function() { reference.set('/nodeTarget.nested'); expect(reference.getValue()).to.equal('/nodeTarget.nested'); }); - it('set with something else should throw', function () { - expect(function () { reference.set(123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); + it('set with something else should throw', function() { + expect(function() { reference.set(123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); }); - it('setValue with a Property should work', function () { + it('setValue with a Property should work', function() { reference.setValue(nestedChild); expect(reference.getValue()).to.equal('/nodeTarget.nested'); }); - it('setValue with a path should work', function () { + it('setValue with a path should work', function() { reference.setValue('/nodeTarget.nested'); expect(reference.getValue()).to.equal('/nodeTarget.nested'); }); - it('setValue with something else should throw', function () { - expect(function () { reference.setValue(123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); + it('setValue with something else should throw', function() { + expect(function() { reference.setValue(123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); }); - it('should have a working isReferenceValid', function () { + it('should have a working isReferenceValid', function() { // An empty reference should be valid reference.value = ''; expect(reference.isReferenceValid()).to.be.true; @@ -309,7 +307,7 @@ describe('Reference Properties', function () { expect(reference.isReferenceValid()).to.be.false; }); - it('should allow dereferencing via a *', function () { + it('should allow dereferencing via a *', function() { reference.set(target); expect(root.resolvePath('/reference')).to.equal(target); expect(root.resolvePath('/reference*')).to.equal(reference); @@ -318,14 +316,14 @@ describe('Reference Properties', function () { expect(root.get(['reference', dereferenceToken])).to.equal(reference); }); - it('should allow dereferencing via a * with nested reference property', function () { + it('should allow dereferencing via a * with nested reference property', function() { reference.set(target); reference2.set('/reference*'); expect(root.get('reference2')).to.equal(reference); expect(root.resolvePath('/reference2')).to.equal(reference); }); - it('should allow dereferencing via multiple jumps', function () { + it('should allow dereferencing via multiple jumps', function() { let reference3 = PropertyFactory.create('Reference'); let reference4 = PropertyFactory.create('Reference'); let reference5 = PropertyFactory.create('Reference'); @@ -349,7 +347,7 @@ describe('Reference Properties', function () { expect(root.resolvePath('/reference')).to.equal(target); }); - it('should allow dereferencing via * multiple jumps', function () { + it('should allow dereferencing via * multiple jumps', function() { let reference3 = PropertyFactory.create('Reference'); let reference4 = PropertyFactory.create('Reference'); let reference5 = PropertyFactory.create('Reference'); @@ -373,8 +371,7 @@ describe('Reference Properties', function () { expect(root.resolvePath('/reference')).to.equal(target); }); - - it('should allow accessing nested paths', function () { + it('should allow accessing nested paths', function() { reference.set(nodeTarget); expect(root.resolvePath('/reference.nested')).to.equal(nestedChild); @@ -386,14 +383,14 @@ describe('Reference Properties', function () { expect(root.resolvePath('/reference.nested').value).to.equal('test_value'); }); - it('should allow accessing referenced maps', function () { + it('should allow accessing referenced maps', function() { reference.set(mapTarget); expect(root.resolvePath('/reference[nested]')).to.equal(nestedMapChild); expect(root.resolvePath('/reference*[nested]')).to.equal(undefined); }); - it('should allow accessing referenced arrays', function () { + it('should allow accessing referenced arrays', function() { reference.set(arrayTarget); expect(root.resolvePath('/reference[0]')).to.equal(nestedArrayChild); @@ -401,14 +398,14 @@ describe('Reference Properties', function () { expect(root.resolvePath('/reference*[0]')).to.equal(undefined); }); - it('forwarding should work over multiple jumps', function () { + it('forwarding should work over multiple jumps', function() { reference.set(nodeTarget); reference2.set(reference); expect(root.resolvePath('/reference2.nested')).to.equal(nestedChild); }); - it('should continue to work when the reference or the referenced node changes', function () { + it('should continue to work when the reference or the referenced node changes', function() { reference.set(nodeTarget); expect(root.resolvePath('/reference.nested')).to.equal(nestedChild); expect(root.get(['reference', 'nested'])).to.equal(nestedChild); @@ -424,18 +421,18 @@ describe('Reference Properties', function () { expect(root.get(['reference', 'nested'])).to.equal(newChild); }); - it('should work with relative paths using getReferencedProperty', function () { + it('should work with relative paths using getReferencedProperty', function() { relativeReference.setValue('../nodeTarget2'); expect(relativeReference.get()).to.equal(nodeTarget2); }); - it('should work with relative paths using getReferencedProperty', function () { + it('should work with relative paths using getReferencedProperty', function() { relativeReference.setValue('../nodeTarget2'); expect(relativeReference.get()).to.equal(nodeTarget2); expect(relativeReference.ref).to.equal(nodeTarget2); }); - it('should work with multiple jumps with relative references', function () { + it('should work with multiple jumps with relative references', function() { relativeReference.setValue('../nodeTarget'); relativeReference2.setValue('../nodeTarget.relativeReference'); expect(root.resolvePath('/nodeTarget2.relativeReference2.nested')).to.equal(nestedChild); @@ -449,35 +446,33 @@ describe('Reference Properties', function () { { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NO_LEAFS }).get(['nested'])).to.equal(nestedChild); }); - - it('should return undefined when going beyond the root', function () { + it('should return undefined when going beyond the root', function() { relativeReference.setValue('../../nodeTarget2'); expect(relativeReference.get()).to.be.undefined; }); - it('should clone', function () { + it('should clone', function() { var clone = relativeReference.clone(); expect(relativeReference._serialize(false)).to.eql(clone._serialize(false)); }); - it('get context should return single', function () { + it('get context should return single', function() { expect(reference.getContext()).to.equal('single'); }); - it('getFullTypeid should work', function () { + it('getFullTypeid should work', function() { expect(reference.getFullTypeid()).to.equal('Reference'); expect(reference.getFullTypeid(false)).to.equal('Reference'); }); - it('isPrimitiveType should evaluate to true', function () { + it('isPrimitiveType should evaluate to true', function() { expect(reference.isPrimitiveType()).to.equal(true); }); - }); }); - describe('ReferenceMapProperty', function () { - it('should be possible to create', function () { + describe('ReferenceMapProperty', function() { + it('should be possible to create', function() { // Test creation of an anonymous reference var reference = PropertyFactory.create('Reference', 'map'); expect(reference).to.be.instanceof(ReferenceMapProperty); @@ -501,7 +496,7 @@ describe('Reference Properties', function () { expect(prop._properties.refMap.getReferenceTargetTypeId()).to.equal('NodeProperty'); }); - it('empty reference should resolve to undefined', function () { + it('empty reference should resolve to undefined', function() { var reference = PropertyFactory.create('Reference', 'map'); // It should work for missing entries @@ -512,7 +507,7 @@ describe('Reference Properties', function () { expect(reference.get('test')).to.be.undefined; }); - it('setting a referenced member to undefined should turn it into an empty string', function () { + it('setting a referenced member to undefined should turn it into an empty string', function() { var reference = PropertyFactory.create('Reference', 'map'); // First set it to something else than an empty reference @@ -526,22 +521,21 @@ describe('Reference Properties', function () { expect(reference.getValue('test')).to.equal(''); expect(reference.getValue('test2')).to.equal(''); expect(reference.get('test')).to.be.undefined; - }); - it('setting a reference to a non absolute path should not throw', function () { + it('setting a reference to a non absolute path should not throw', function() { var reference = PropertyFactory.create('Reference', 'map'); - expect(function () { reference.set('test', 'test'); }).to.not.throw(); - expect(function () { reference.insert('test2', 'test'); }).to.not.throw(); + expect(function() { reference.set('test', 'test'); }).to.not.throw(); + expect(function() { reference.insert('test2', 'test'); }).to.not.throw(); }); - describe('Reference resolution', function () { + describe('Reference resolution', function() { var root, target, reference, reference2, reference3, reference4, relativeReference; var nodeTarget, nestedChild, nodeTarget2, nestedChild2; var mapTarget, nestedMapChild; var arrayTarget, nestedArrayChild; - beforeEach(function () { + beforeEach(function() { root = PropertyFactory.create('NodeProperty'); target = PropertyFactory.create('String'); @@ -582,14 +576,14 @@ describe('Reference Properties', function () { target.value = 'test'; }); - it('should allow resolving references', function () { + it('should allow resolving references', function() { reference.setValue('test', '/target'); expect(reference.get('test')).to.equal(target); expect(reference.get('test').value).to.equal('test'); }); - it('@bugfix should allow dereferencing via a * with reference map property', function () { + it('@bugfix should allow dereferencing via a * with reference map property', function() { reference4.set(target); reference3.set('/reference4*'); reference.setValue('test', '/reference3'); @@ -598,7 +592,7 @@ describe('Reference Properties', function () { expect(reference.get('test2')).to.equal(reference3); }); - it('should support setting via set', function () { + it('should support setting via set', function() { reference.set('test', target); expect(reference.get('test')).to.equal(target); @@ -606,55 +600,55 @@ describe('Reference Properties', function () { expect(reference.getValue('test')).to.equal('/target'); }); - it('set (insert) with a Property should work', function () { + it('set (insert) with a Property should work', function() { reference.set('test', nestedChild); expect(reference.getValue('test')).to.equal('/nodeTarget.nested'); }); - it('set (insert) with a path should work', function () { + it('set (insert) with a path should work', function() { reference.set('test', '/nodeTarget.nested'); expect(reference.getValue('test')).to.equal('/nodeTarget.nested'); }); - it('set (insert) with something else should throw', function () { - expect(function () { reference.set('test', 123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); + it('set (insert) with something else should throw', function() { + expect(function() { reference.set('test', 123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); }); - it('set (modify) with a Property should work', function () { + it('set (modify) with a Property should work', function() { reference.set('test'); expect(reference.getValue('test')).to.equal(''); reference.set('test', nestedChild); expect(reference.getValue('test')).to.equal('/nodeTarget.nested'); }); - it('set (modify) with a path should work', function () { + it('set (modify) with a path should work', function() { reference.set('test'); expect(reference.getValue('test')).to.equal(''); reference.set('test', '/nodeTarget.nested'); expect(reference.getValue('test')).to.equal('/nodeTarget.nested'); }); - it('set (modify) with something else should throw', function () { + it('set (modify) with something else should throw', function() { reference.set('test'); expect(reference.getValue('test')).to.equal(''); - expect(function () { reference.set('test', 123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); + expect(function() { reference.set('test', 123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); }); - it('insert with a Property should work', function () { + it('insert with a Property should work', function() { reference.insert('test', nestedChild); expect(reference.getValue('test')).to.equal('/nodeTarget.nested'); }); - it('insert with a path should work', function () { + it('insert with a path should work', function() { reference.insert('test', '/nodeTarget.nested'); expect(reference.getValue('test')).to.equal('/nodeTarget.nested'); }); - it('insert with something else should throw', function () { - expect(function () { reference.insert('test', 123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); + it('insert with something else should throw', function() { + expect(function() { reference.insert('test', 123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); }); - it('setValues with Property and path should work', function () { + it('setValues with Property and path should work', function() { reference.setValues([nestedChild, '/nodeTarget.nested']); expect(reference.getValue(0)).to.equal('/nodeTarget.nested'); expect(reference.getValue(1)).to.equal('/nodeTarget.nested'); @@ -668,11 +662,11 @@ describe('Reference Properties', function () { expect(reference.getValue('test2')).to.equal('/nodeTarget.nested'); }); - it('setValues with something else should throw', function () { - expect(function () { reference.setValues({ 'test': 123 }); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); + it('setValues with something else should throw', function() { + expect(function() { reference.setValues({ 'test': 123 }); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); }); - it('should have a working isReferenceValid', function () { + it('should have a working isReferenceValid', function() { // An empty reference should be valid reference.setValue('test', ''); expect(reference.isReferenceValid('test')).to.be.true; @@ -686,36 +680,36 @@ describe('Reference Properties', function () { expect(reference.isReferenceValid('test')).to.be.false; }); - it('should allow dereferencing via the array syntax', function () { + it('should allow dereferencing via the array syntax', function() { reference.set('test', target); expect(root.resolvePath('/reference[test]')).to.equal(target); }); - it('should allow accessing nested paths', function () { + it('should allow accessing nested paths', function() { reference.insert('test', nodeTarget); expect(root.resolvePath('/reference[test].nested')).to.equal(nestedChild); }); - it('should allow accessing referenced maps', function () { + it('should allow accessing referenced maps', function() { reference.set('test', mapTarget); expect(root.resolvePath('/reference[test][nested]')).to.equal(nestedMapChild); }); - it('should allow accessing referenced arrays', function () { + it('should allow accessing referenced arrays', function() { reference.set('test', arrayTarget); expect(root.resolvePath('/reference[test][0]')).to.equal(nestedArrayChild); }); - it('double dereferencing a reference should work', function () { + it('double dereferencing a reference should work', function() { reference.set('test', target); reference2.set('test', reference); expect(root.resolvePath('/reference2[test][test]')).to.equal(target); }); - it('mixing maps and normal maps should work', function () { + it('mixing maps and normal maps should work', function() { reference.set('test', target); reference3.set(reference); @@ -731,7 +725,7 @@ describe('Reference Properties', function () { expect(root.get(['reference', 'test', dereferenceToken])); }); - it('should continue to work when the reference or the referenced node changes', function () { + it('should continue to work when the reference or the referenced node changes', function() { reference.insert('test', nodeTarget); expect(root.resolvePath('/reference[test].nested')).to.equal(nestedChild); expect(reference.resolvePath('[test].nested')).to.equal(nestedChild); @@ -746,37 +740,36 @@ describe('Reference Properties', function () { expect(reference.resolvePath('[test].nested')).to.equal(newChild); }); - it('should allow dereferencing via the array syntax using relative paths', function () { + it('should allow dereferencing via the array syntax using relative paths', function() { relativeReference.setValue('test', '../target'); expect(root.resolvePath('/nodeTarget.relativeReference[test]')).to.equal(target); }); - - it('remove should work and return the string path', function () { + it('remove should work and return the string path', function() { reference.insert('two', target); expect(reference.remove('two')).to.equal('/target'); expect(reference.getValue('two')).to.be.undefined; }); - it('getValues should return a map containing path strings', function () { + it('getValues should return a map containing path strings', function() { var newReference = PropertyFactory.create('Reference', 'map'); newReference.insert('one', target); newReference.insert('two', nodeTarget); expect(newReference.getValues()).to.deep.equal({ 'one': '/target', - 'two': '/nodeTarget' + 'two': '/nodeTarget', }); }); - it('getContext should return map', function () { + it('getContext should return map', function() { var newReference = PropertyFactory.create('Reference', 'map'); expect(newReference.getContext()).to.equal('map'); }); }); }); - describe('ReferenceArrayProperty', function () { - it('should be possible to create', function () { + describe('ReferenceArrayProperty', function() { + it('should be possible to create', function() { // Test creation of an anonymous reference var reference = PropertyFactory.create('Reference', 'array'); expect(reference).to.be.instanceof(ReferenceArrayProperty); @@ -800,7 +793,7 @@ describe('Reference Properties', function () { expect(prop._properties.refArray.getReferenceTargetTypeId()).to.equal('NodeProperty'); }); - it('empty reference should resolve to undefined', function () { + it('empty reference should resolve to undefined', function() { var reference = PropertyFactory.create('Reference', 'array'); // Explicitly setting it should have the same effect @@ -813,7 +806,7 @@ describe('Reference Properties', function () { expect(reference.getValue(0)).to.equal(''); }); - it('setting a referenced member to undefined should turn it into an empty string', function () { + it('setting a referenced member to undefined should turn it into an empty string', function() { var reference = PropertyFactory.create('Reference', 'array'); // Test pushing a value @@ -830,19 +823,19 @@ describe('Reference Properties', function () { expect(reference.get(0)).to.equal(undefined); }); - it.skip('setting a reference to a non absolute path should not throw', function () { + it.skip('setting a reference to a non absolute path should not throw', function() { var reference = PropertyFactory.create('Reference', 'array'); - expect(function () { reference.push('test'); }).to.throw(); - expect(function () { reference.push(''); reference.set(0, 'test'); }).to.throw(); + expect(function() { reference.push('test'); }).to.throw(); + expect(function() { reference.push(''); reference.set(0, 'test'); }).to.throw(); }); - describe('Reference resolution', function () { + describe('Reference resolution', function() { var root, target, reference, reference2, reference3, relativeReference; var nodeTarget, nestedChild, nodeTarget2, nestedChild2; var mapTarget, nestedMapChild; var arrayTarget, nestedArrayChild; - beforeEach(function () { + beforeEach(function() { root = PropertyFactory.create('NodeProperty'); nodeTarget = PropertyFactory.create('NodeProperty'); @@ -881,14 +874,14 @@ describe('Reference Properties', function () { target.value = 'test'; }); - it('should allow resolving references', function () { + it('should allow resolving references', function() { reference.push('/target'); expect(reference.get(0)).to.equal(target); expect(reference.get(0).value).to.equal('test'); }); - it('should support setting via push', function () { + it('should support setting via push', function() { reference.push(target); expect(reference.get(0)).to.equal(target); @@ -897,7 +890,7 @@ describe('Reference Properties', function () { // this last test will break when we get rid of getReferencedProperty. Fix when get supports '*' }); - it('should support setting via insert', function () { + it('should support setting via insert', function() { reference.insert(0, target); expect(reference.get(0)).to.equal(target); @@ -906,7 +899,7 @@ describe('Reference Properties', function () { // see comment above }); - it('should support setting via insertRange', function () { + it('should support setting via insertRange', function() { reference.insertRange(0, [target, nodeTarget]); expect(reference.get(0)).to.equal(target); @@ -918,7 +911,7 @@ describe('Reference Properties', function () { // see comment above }); - it('should support setting via setRange', function () { + it('should support setting via setRange', function() { reference.insertRange(0, ['', '']); reference.setRange(0, [target, nodeTarget]); @@ -931,7 +924,7 @@ describe('Reference Properties', function () { // see comment above }); - it('should support setting via set', function () { + it('should support setting via set', function() { reference.insertRange(0, ['', '']); reference.set(0, target); reference.set(1, nodeTarget); @@ -945,34 +938,34 @@ describe('Reference Properties', function () { // to fix once .get accepts '*' tokens }); - it('set with a Property should work', function () { + it('set with a Property should work', function() { reference.insert(0); expect(reference.getValue(0)).to.equal(''); reference.set(0, nestedChild); expect(reference.getValue(0)).to.equal('/nodeTarget.nested'); }); - it('set with a path should work', function () { + it('set with a path should work', function() { reference.insert(0); expect(reference.getValue(0)).to.equal(''); reference.set(0, '/nodeTarget.nested'); expect(reference.getValue(0)).to.equal('/nodeTarget.nested'); }); - it('set with something else should throw', function () { + it('set with something else should throw', function() { reference.insert(0); expect(reference.getValue(0)).to.equal(''); - expect(function () { reference.set(0, 123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); + expect(function() { reference.set(0, 123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); }); - it('set should throw if in_offset is not an integer', function () { + it('set should throw if in_offset is not an integer', function() { reference.insert(0); expect(reference.getValue(0)).to.equal(''); - expect(function () { reference.set('test', '/nodeTarget.nested'); }) + expect(function() { reference.set('test', '/nodeTarget.nested'); }) .to.throw(MSG.NOT_NUMBER); }); - it('setRange with a Property and a path should work', function () { + it('setRange with a Property and a path should work', function() { reference.insert(0); reference.insert(1); expect(reference.getValue(0)).to.equal(''); @@ -983,88 +976,88 @@ describe('Reference Properties', function () { expect(reference.getValue(1)).to.equal('/nodeTarget.nested'); }); - it('setRange with something else should throw', function () { + it('setRange with something else should throw', function() { reference.insert(0); expect(reference.getValue(0)).to.equal(''); - expect(function () { reference.setRange(0, [123]); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); + expect(function() { reference.setRange(0, [123]); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); }); - it('setRange should throw if in_offset is not an integer', function () { + it('setRange should throw if in_offset is not an integer', function() { reference.insert(0); reference.insert(1); expect(reference.getValue(0)).to.equal(''); expect(reference.getValue(1)).to.equal(''); - expect(function () { reference.setRange('test', [nestedChild, '/nodeTarget.nested']); }) + expect(function() { reference.setRange('test', [nestedChild, '/nodeTarget.nested']); }) .to.throw(MSG.NOT_NUMBER); }); - it('insert with a Property should work', function () { + it('insert with a Property should work', function() { reference.insert(0, nestedChild); expect(reference.getValue(0)).to.equal('/nodeTarget.nested'); }); - it('insert with a path should work', function () { + it('insert with a path should work', function() { reference.insert(0, '/nodeTarget.nested'); expect(reference.getValue(0)).to.equal('/nodeTarget.nested'); }); - it('insert with something else should throw', function () { - expect(function () { reference.insert(0, 123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); + it('insert with something else should throw', function() { + expect(function() { reference.insert(0, 123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); }); - it('insertRange with a Property and a path should work', function () { + it('insertRange with a Property and a path should work', function() { reference.insertRange(0, [nestedChild, '/nodeTarget.nested']); expect(reference.getValue(0)).to.equal('/nodeTarget.nested'); expect(reference.getValue(1)).to.equal('/nodeTarget.nested'); }); - it('insertRange with something else should throw', function () { - expect(function () { reference.insertRange(0, [123]); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); + it('insertRange with something else should throw', function() { + expect(function() { reference.insertRange(0, [123]); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); }); - it('enqueue with a Property should work', function () { + it('enqueue with a Property should work', function() { reference.enqueue(nestedChild); expect(reference.getValue(0)).to.equal('/nodeTarget.nested'); }); - it('enqueue with a path should work', function () { + it('enqueue with a path should work', function() { reference.enqueue('/nodeTarget.nested'); expect(reference.getValue(0)).to.equal('/nodeTarget.nested'); }); - it('enqueue with something else should throw', function () { - expect(function () { reference.enqueue(123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); + it('enqueue with something else should throw', function() { + expect(function() { reference.enqueue(123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); }); - it('push with a Property should work', function () { + it('push with a Property should work', function() { reference.push(nestedChild); expect(reference.getValue(0)).to.equal('/nodeTarget.nested'); }); - it('push with a path should work', function () { + it('push with a path should work', function() { reference.push('/nodeTarget.nested'); expect(reference.getValue(0)).to.equal('/nodeTarget.nested'); }); - it('push with something else should throw', function () { - expect(function () { reference.push(123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); + it('push with something else should throw', function() { + expect(function() { reference.push(123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); }); - it('unshift with a Property should work', function () { + it('unshift with a Property should work', function() { reference.unshift(nestedChild); expect(reference.getValue(0)).to.equal('/nodeTarget.nested'); }); - it('unshift with a path should work', function () { + it('unshift with a path should work', function() { reference.unshift('/nodeTarget.nested'); expect(reference.getValue(0)).to.equal('/nodeTarget.nested'); }); - it('unshift with something else should throw', function () { - expect(function () { reference.unshift(123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); + it('unshift with something else should throw', function() { + expect(function() { reference.unshift(123); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); }); - it('setValues with Property and path should work', function () { + it('setValues with Property and path should work', function() { reference.setValues([nestedChild, '/nodeTarget.nested']); expect(reference.getValue(0)).to.equal('/nodeTarget.nested'); expect(reference.getValue(1)).to.equal('/nodeTarget.nested'); @@ -1078,11 +1071,11 @@ describe('Reference Properties', function () { expect(reference.getValue(1)).to.equal('/nodeTarget.nested'); }); - it('setValues with something else should throw', function () { - expect(function () { reference.setValues({ 0: 123 }); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); + it('setValues with something else should throw', function() { + expect(function() { reference.setValues({ 0: 123 }); }).to.throw(MSG.PROPERTY_OR_UNDEFINED); }); - it('should have a working isReferenceValid', function () { + it('should have a working isReferenceValid', function() { // An empty reference should be valid reference.push(''); expect(reference.isReferenceValid(0)).to.be.true; @@ -1096,38 +1089,38 @@ describe('Reference Properties', function () { expect(reference.isReferenceValid(0)).to.be.false; }); - it('should allow dereferencing via the array syntax', function () { + it('should allow dereferencing via the array syntax', function() { reference.push(target); expect(root.resolvePath('/reference[0]')).to.equal(target); }); - it('should allow accessing nested paths', function () { + it('should allow accessing nested paths', function() { reference.push(nodeTarget); expect(root.resolvePath('/reference[0].nested')).to.equal(nestedChild); }); - it('should allow accessing referenced maps', function () { + it('should allow accessing referenced maps', function() { reference.push(mapTarget); expect(root.resolvePath('/reference[0][nested]')).to.equal(nestedMapChild); }); - it('should allow accessing referenced arrays', function () { + it('should allow accessing referenced arrays', function() { reference.push(arrayTarget); expect(root.resolvePath('/reference[0][0]')).to.equal(nestedArrayChild); }); - it('double dereferencing a reference should work', function () { + it('double dereferencing a reference should work', function() { reference.push(target); reference2.push(reference); expect(root.resolvePath('/reference2[0][0]')).to.equal(target); }); - it('mixing references and array references should work', function () { + it('mixing references and array references should work', function() { reference.push(target); reference3.set(reference); @@ -1141,7 +1134,7 @@ describe('Reference Properties', function () { expect(root.resolvePath('/reference[0]*')).to.equal(reference3); }); - it('should continue to work when the reference or the referenced node changes', function () { + it('should continue to work when the reference or the referenced node changes', function() { reference.push(nodeTarget); expect(root.resolvePath('/reference[0].nested')).to.equal(nestedChild); @@ -1157,12 +1150,12 @@ describe('Reference Properties', function () { expect(reference.resolvePath('[0].nested')).to.equal(newChild); }); - it('should allow dereferencing via the array syntax using relative paths', function () { + it('should allow dereferencing via the array syntax using relative paths', function() { relativeReference.push('../target'); expect(root.resolvePath('/nodeTarget.relativeReference[0]')).to.equal(target); }); - it('Should return references value when a reference points to a context simple property', function () { + it('Should return references value when a reference points to a context simple property', function() { let test = PropertyFactory.create('NodeProperty'); let ref = PropertyFactory.create('Reference'); let nameProperty = PropertyFactory.create('NamedProperty'); @@ -1171,22 +1164,22 @@ describe('Reference Properties', function () { test.resolvePath('reference*').set(nameProperty); expect(test.getValues()).to.deep.equal({ b: { - guid: nameProperty.getGuid() + guid: nameProperty.getGuid(), }, reference: { - guid: nameProperty.getGuid() - } + guid: nameProperty.getGuid(), + }, }); }); - it('.pop should work', function () { + it('.pop should work', function() { reference.insertRange(0, [target, nodeTarget]); expect(reference.length).to.equal(2); reference.pop(); expect(reference.length).to.equal(1); expect(reference.pop()).to.equal('/target'); }); - it('.remove and .removeRange should work', function () { + it('.remove and .removeRange should work', function() { reference.insertRange(0, [target, nodeTarget]); expect(reference.length).to.equal(2); expect(reference.remove(0)).to.equal('/target'); @@ -1195,16 +1188,16 @@ describe('Reference Properties', function () { expect(reference.removeRange(0, 2)).to.deep.equal(['/nodeTarget', '/target']); expect(reference.length).to.equal(0); }); - it('.getValues should work', function () { + it('.getValues should work', function() { reference.insertRange(0, [target, nodeTarget]); expect(reference.getValues()).to.deep.equal(['/target', '/nodeTarget']); }); }); }); - describe('Changeset tests', function () { + describe('Changeset tests', function() { var root; - beforeEach(function () { + beforeEach(function() { root = PropertyFactory.create('NodeProperty'); root.insert('template', PropertyFactory.create('autodesk.test:referencePropertyTest-1.0.0')); root.insert('reference', PropertyFactory.create('Reference')); @@ -1236,7 +1229,7 @@ describe('Reference Properties', function () { root._properties.template.refArray_anon.push(target); }); - it('serialize and deserialize should work', function () { + it('serialize and deserialize should work', function() { var root2 = PropertyFactory.create('NodeProperty'); root2.deserialize(root.serialize()); expect(root.serialize({ 'dirtyOnly': false })).to.deep.equal(root.serialize({ 'dirtyOnly': false })); @@ -1259,7 +1252,7 @@ describe('Reference Properties', function () { expect(root2._properties.template.refArray_anon.get()).to.deep.equal(root2Target); }); - it('squash should work', function () { + it('squash should work', function() { var CS1 = root.serialize({ 'dirtyOnly': false }); root.cleanDirty(); @@ -1292,7 +1285,7 @@ describe('Reference Properties', function () { expect(squashed.getSerializedChangeSet()).to.deep.equal(root.serialize({ 'dirtyOnly': false })); }); - it('rebase should work', function () { + it('rebase should work', function() { root.cleanDirty(); root.insert('target2', PropertyFactory.create('String')); @@ -1344,6 +1337,5 @@ describe('Reference Properties', function () { expect(conflicts[i].type).to.equal(ChangeSet.ConflictType.INSERTED_ENTRY_WITH_SAME_KEY); } }); - }); }); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/relationshipProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/relationshipProperty.spec.js index 931d74d0efcb..fbf64cf4670b 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/relationshipProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/relationshipProperty.spec.js @@ -2,25 +2,24 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /** * @fileoverview In this file, we will test the relationship property * added to /src/property_factory.js */ const { PropertyFactory } = require('../..'); -describe('RelationshipProperty', function () { - - it('should be able to add a relationship property whithin a schema', function () { +describe('RelationshipProperty', function() { + it('should be able to add a relationship property whithin a schema', function() { const assetSchema = { typeid: 'foo:bar-1.0.0', inherits: ['NodeProperty'], properties: [ { id: 'relationship', - typeid: 'RelationshipProperty' - } - ] + typeid: 'RelationshipProperty', + }, + ], }; PropertyFactory.register(assetSchema); let str = PropertyFactory.create('String'); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/setProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/setProperty.spec.js index cdb1b025d486..947e8037d3e6 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/setProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/setProperty.spec.js @@ -2,23 +2,23 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /** * @fileoverview In this file, we will test the set property * object described in /src/properties/setProperty.js */ +const { ChangeSet } = require('@fluid-experimental/property-changeset'); +const { generateGUID } = require('@fluid-experimental/property-common').GuidUtils; const _ = require('lodash'); const { PropertyFactory } = require('../..'); const { BaseProperty } = require('../..'); -const { ChangeSet } = require('@fluid-experimental/property-changeset') -const { generateGUID } = require('@fluid-experimental/property-common').GuidUtils; -describe('SetProperty', function () { +describe('SetProperty', function() { var PATH_TOKENS; var changeSetWithTwoChildren, changeSetWithTwoChildren_full, removalChangeSet; var myNode, childNode1, childNode2, children; - before(function () { + before(function() { PATH_TOKENS = BaseProperty.PATH_TOKENS; // Register a template with a set property for the tests @@ -28,8 +28,8 @@ describe('SetProperty', function () { properties: [ { id: 'stringProperty', typeid: 'String' }, { id: 'stringProperty2', typeid: 'String' }, - { id: 'children', context: 'set', typeid: 'NamedProperty' } - ] + { id: 'children', context: 'set', typeid: 'NamedProperty' }, + ], }; PropertyFactory._reregister(TestPropertyTemplate); @@ -43,7 +43,7 @@ describe('SetProperty', function () { // Helper functions for the test cases // Inserts a node with the given guid (a new one is generated when undefined) - var insertNodeInRootWithGuid = function (guid, root) { + var insertNodeInRootWithGuid = function(guid, root) { var child = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); if (guid) { child._properties.guid.value = guid; @@ -52,17 +52,17 @@ describe('SetProperty', function () { }; // Inserts a new node in the root - var insertNodeInRoot = function (root) { + var insertNodeInRoot = function(root) { insertNodeInRootWithGuid(generateGUID(), root); }; // Returns a function that will insert a node with a constant GUID - var insertUniqueNodeInRoot = function () { + var insertUniqueNodeInRoot = function() { return insertNodeInRootWithGuid.bind(undefined, generateGUID()); }; // Inserts a new node as leaf - var insertNodeAsLeaf = function (root) { + var insertNodeAsLeaf = function(root) { var leaf = root; while (leaf._properties.children.getAsArray().length > 0) { leaf = leaf._properties.children.getAsArray()[0]; @@ -72,13 +72,13 @@ describe('SetProperty', function () { }; // Removes the first node from the root - var removeFirstNodeInRoot = function (root) { + var removeFirstNodeInRoot = function(root) { var firstChild = root._properties.children.getAsArray()[0]; root._properties.children.remove(firstChild); }; // Modifies the leaf node - var modifyLeaf = function (root) { + var modifyLeaf = function(root) { var leaf = root; while (leaf._properties.children.getAsArray().length > 0) { leaf = leaf._properties.children.getAsArray()[0]; @@ -86,15 +86,13 @@ describe('SetProperty', function () { leaf._properties.stringProperty.value = leaf._properties.stringProperty.value + '+'; }; - - describe('Testing creation, assignment and serialization', function () { - - it('should be empty at the beginning', function () { + describe('Testing creation, assignment and serialization', function() { + it('should be empty at the beginning', function() { expect(children.getEntriesReadOnly()).to.be.empty; expect(children._serialize(true)).to.be.empty; }); - it('should be possible to insert children', function () { + it('should be possible to insert children', function() { // Test insertion of the first child children.insert(childNode1); expect(children.has(childNode1.getGuid())).to.be.ok; @@ -121,14 +119,14 @@ describe('SetProperty', function () { _.includes( _.keys( changeSetWithTwoChildren.insert['autodesk.tests:TestPropertyID-1.0.0']), - childNode2.getGuid()) + childNode2.getGuid()), ).to.be.ok; changeSetWithTwoChildren_full = children.serialize({ 'dirtyOnly': false }); expect(changeSetWithTwoChildren).to.deep.equal(changeSetWithTwoChildren_full); }); - it('.get and .resolvePath should work', function () { + it('.get and .resolvePath should work', function() { expect(children.get(childNode1.getGuid())).to.equal(childNode1); expect(children.resolvePath('/children[' + childNode1.getGuid() + ']')).to.equal(childNode1); expect(children.get([PATH_TOKENS.ROOT, 'children', childNode1.getGuid()])).to.equal(childNode1); @@ -136,7 +134,7 @@ describe('SetProperty', function () { expect(children.get([PATH_TOKENS.UP, 'children', childNode1.getGuid()])).to.equal(childNode1); }); - it('.remove should return the item removed', function () { + it('.remove should return the item removed', function() { var myNode1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var childNode3 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var childNode4 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); @@ -147,7 +145,7 @@ describe('SetProperty', function () { expect(mySet.remove(childNode4.getGuid())).to.deep.equal(childNode4); }); - it('getValues should work', function () { + it('getValues should work', function() { var myNode1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var childNode3 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var childNode4 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); @@ -157,7 +155,7 @@ describe('SetProperty', function () { var guid = myNode1.getGuid(); var guidChild3 = childNode3.getGuid(); var guidChild4 = childNode4.getGuid(); - expect(function () { myNode1.getValues(); }).to.not.throw(); + expect(function() { myNode1.getValues(); }).to.not.throw(); var expectedStr = '{"stringProperty":"",' + '"stringProperty2":"",' + '"children":{"' + @@ -173,7 +171,7 @@ describe('SetProperty', function () { expect(JSON.stringify(myNode1.getValues())).to.equal(expectedStr); }); - it('should output a pretty string with prettyPrint()', function () { + it('should output a pretty string with prettyPrint()', function() { var guid = myNode.getGuid(); var guidChild1 = childNode1.getGuid(); var guidChild2 = childNode2.getGuid(); @@ -195,13 +193,13 @@ describe('SetProperty', function () { ' guid (String): "' + guidChild2 + '"\n' + ' guid (String): "' + guid + '"\n'; var prettyStr = ''; - myNode.prettyPrint(function (str) { + myNode.prettyPrint(function(str) { prettyStr += str + '\n'; }); expect(prettyStr).to.equal(expectedPrettyStr); }); - it('Should track dirtiness', function () { + it('Should track dirtiness', function() { children.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY); expect(children._serialize(true, false, BaseProperty.MODIFIED_STATE_FLAGS.DIRTY)).to.be.empty; expect(children._serialize(true, false, @@ -209,8 +207,7 @@ describe('SetProperty', function () { expect(children.serialize({ 'dirtyOnly': false })).deep.equal(changeSetWithTwoChildren_full); }); - - it('Should handle removals correctly', function () { + it('Should handle removals correctly', function() { children.remove(childNode1); expect(childNode1.getParent()).to.be.undefined; children.remove(childNode2.getGuid()); @@ -219,16 +216,15 @@ describe('SetProperty', function () { removalChangeSet = children.serialize({ 'dirtyOnly': true, 'includeRootTypeid': false, - 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY + 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY, }); expect(removalChangeSet).to.have.all.keys(['remove']); expect(removalChangeSet.remove).to.have.length(2); expect(removalChangeSet.remove).to.contain(childNode1.getGuid()); expect(removalChangeSet.remove).to.contain(childNode1.getGuid()); - }); - it('Should support deserialization', function () { + it('Should support deserialization', function() { var deserializedNode = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var deserializedChanges1 = deserializedNode._properties.children.deserialize(changeSetWithTwoChildren); var CS4 = deserializedNode._properties.children.serialize({ 'dirtyOnly': false }); @@ -242,7 +238,7 @@ describe('SetProperty', function () { expect(deserializedChanges3).to.deep.equal(removalChangeSet); }); - it('Should support deserialization for inserts and removes', function () { + it('Should support deserialization for inserts and removes', function() { var deserializedNode = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var deserializedNode2 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); @@ -258,11 +254,10 @@ describe('SetProperty', function () { deserializedNode.serialize({ 'dirtyOnly': false })); }); - it('Should track modifies', function () { + it('Should track modifies', function() { var modifyNode1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var modifyNode2 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); - modifyNode1._properties.children.deserialize(changeSetWithTwoChildren); modifyNode2._properties.children.deserialize(changeSetWithTwoChildren); @@ -276,7 +271,7 @@ describe('SetProperty', function () { .to.deep.equal(modifyNode1._properties.children._serialize(false)); }); - it('Should support hierarchical properties', function () { + it('Should support hierarchical properties', function() { var node1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var node2 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var node3 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); @@ -309,7 +304,7 @@ describe('SetProperty', function () { expect(child2._properties.stringProperty.value).to.equal('test2'); }); - it('adding a NamedNodeProperty should be possible', function () { + it('adding a NamedNodeProperty should be possible', function() { var set = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0')._properties.children; var namedNodeProp = PropertyFactory.create('NamedNodeProperty'); set.insert(namedNodeProp); @@ -318,7 +313,7 @@ describe('SetProperty', function () { expect(set.get(namedNodeProp.getGuid())).to.equal(namedNodeProp); }); - it('path creation and resolution should work for entries of the map', function () { + it('path creation and resolution should work for entries of the map', function() { var rootNode = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var node = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); rootNode._properties.children.insert(node); @@ -343,30 +338,30 @@ describe('SetProperty', function () { expect(node.getAbsolutePath()).to.equal('/'); }); - describe('Setting values', function () { - before(function () { + describe('Setting values', function() { + before(function() { var SetValueEntryTemplate = { typeid: 'autodesk.tests:SetValueEntry-1.0.0', inherits: ['NamedProperty'], - properties: [{ id: 'string', typeid: 'String' }] + properties: [{ id: 'string', typeid: 'String' }], }; var SetValueTemplate = { typeid: 'autodesk.tests:SetValue-1.0.0', - properties: [{ id: 'set', typeid: 'autodesk.tests:SetValueEntry-1.0.0', context: 'set' }] + properties: [{ id: 'set', typeid: 'autodesk.tests:SetValueEntry-1.0.0', context: 'set' }], }; PropertyFactory.register(SetValueEntryTemplate); PropertyFactory.register(SetValueTemplate); }); - it('should set values for a list of property inputs', function () { + it('should set values for a list of property inputs', function() { var setValueEntry1 = PropertyFactory.create('autodesk.tests:SetValueEntry-1.0.0', null, { - string: 'I am a string 1' + string: 'I am a string 1', }); var setValueEntry2 = PropertyFactory.create('autodesk.tests:SetValueEntry-1.0.0', null, { - string: 'I am a string 2' + string: 'I am a string 2', }); var setValue = PropertyFactory.create('autodesk.tests:SetValue-1.0.0'); @@ -378,7 +373,7 @@ describe('SetProperty', function () { expect(setValue.get('set').getAsArray()[1].get('string').getValue()).to.equal('I am a string 2'); }); - it('should set values for a list of untyped inputs', function () { + it('should set values for a list of untyped inputs', function() { var setValue = PropertyFactory.create('autodesk.tests:SetValue-1.0.0'); setValue.get('set').setValues([{ string: 'I am a string 1' }, { string: 'I am a string 2' }]); @@ -388,13 +383,13 @@ describe('SetProperty', function () { expect(setValue.get('set').getAsArray()[1].get('string').getValue()).to.equal('I am a string 2'); }); - it('should update values for existing keys and create new ones for non-existing keys', function () { + it('should update values for existing keys and create new ones for non-existing keys', function() { var setValueEntry1 = PropertyFactory.create('autodesk.tests:SetValueEntry-1.0.0', null, { - string: 'I am a string 1' + string: 'I am a string 1', }); var setValueEntry2 = PropertyFactory.create('autodesk.tests:SetValueEntry-1.0.0', null, { - string: 'I am a string 2' + string: 'I am a string 2', }); var setValue = PropertyFactory.create('autodesk.tests:SetValue-1.0.0'); @@ -420,7 +415,7 @@ describe('SetProperty', function () { }); }); - describe('squashing', function () { + describe('squashing', function() { // // Helper function which takes a sequence of callbacks that are successively executed // and the changes applied by the callbacks are separately tracked and squashed in a @@ -429,7 +424,7 @@ describe('SetProperty', function () { // Optionally, a a callback which controls the initial state before the squashing can // be given as first parameter // - var testChangeSetSquashing = function (in_options) { + var testChangeSetSquashing = function(in_options) { var testProperty = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var callbacks = in_options.callbacks; @@ -460,58 +455,58 @@ describe('SetProperty', function () { expect(initialChangeset.getSerializedChangeSet()).to.deep.equal(testProperty.serialize()); }; - it('should work for multiple independent inserts', function () { + it('should work for multiple independent inserts', function() { testChangeSetSquashing({ callbacks: [insertNodeInRoot, insertNodeInRoot, insertNodeInRoot] }); }); - it('should work for multiple hierarchical inserts', function () { + it('should work for multiple hierarchical inserts', function() { testChangeSetSquashing({ callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, insertNodeAsLeaf] }); }); - it('should work for inserts followed by removes', function () { + it('should work for inserts followed by removes', function() { testChangeSetSquashing({ callbacks: [insertNodeInRoot, insertNodeInRoot, removeFirstNodeInRoot, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('should work for a tree removal', function () { + it('should work for a tree removal', function() { testChangeSetSquashing({ callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, insertNodeAsLeaf, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('should work for modifies in a tree', function () { + it('should work for modifies in a tree', function() { testChangeSetSquashing({ - callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, insertNodeAsLeaf, modifyLeaf, modifyLeaf] + callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, insertNodeAsLeaf, modifyLeaf, modifyLeaf], }); }); - it('an insert, modify and a remove should give an empty changeset', function () { + it('an insert, modify and a remove should give an empty changeset', function() { testChangeSetSquashing({ callbacks: [insertNodeAsLeaf, insertNodeAsLeaf, modifyLeaf, modifyLeaf, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('work for modifies after an already existing insert', function () { + it('work for modifies after an already existing insert', function() { testChangeSetSquashing({ pre: insertNodeInRoot, - callbacks: [modifyLeaf, modifyLeaf] + callbacks: [modifyLeaf, modifyLeaf], }); }); - it('of modify and remove after an already existing insert should work', function () { + it('of modify and remove after an already existing insert should work', function() { testChangeSetSquashing({ pre: insertNodeInRoot, callbacks: [modifyLeaf, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset['set'].children).to.have.all.keys('remove'); - } + }, }); }); - it('of a replace operation should be possible', function () { + it('of a replace operation should be possible', function() { // Create two nodes with the same GUID var node1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var node2 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); @@ -519,24 +514,24 @@ describe('SetProperty', function () { node2._properties.stringProperty.value = 'testString2'; testChangeSetSquashing({ - pre: function (root) { + pre: function(root) { root._properties.children.insert(node1); }, callbacks: [ removeFirstNodeInRoot, - function (root) { + function(root) { root._properties.children.insert(node2); - } + }, ], - post: function (changeset) { + post: function(changeset) { expect(changeset['set'].children).to.have.all.keys('remove', 'insert'); - } + }, }); }); }); - describe('Rebasing', function () { - var testRebasing = function (in_options) { + describe('Rebasing', function() { + var testRebasing = function(in_options) { // Prepare the initial state var baseProperty1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); if (in_options.prepare) { @@ -595,144 +590,144 @@ describe('SetProperty', function () { } }; - it('with a NOP should be possible', function () { + it('with a NOP should be possible', function() { testRebasing({ op2: insertUniqueNodeInRoot(), - compareToSequential: true + compareToSequential: true, }); }); - it('with independent inserts should be possible', function () { + it('with independent inserts should be possible', function() { testRebasing({ op1: insertUniqueNodeInRoot(), op2: insertUniqueNodeInRoot(), - compareToSequential: true + compareToSequential: true, }); }); - it('with independent removes should be possible', function () { + it('with independent removes should be possible', function() { var node1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var node2 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.children.insert(node1); root._properties.children.insert(node2); }, - op1: function (root) { + op1: function(root) { root._properties.children.remove(node1); }, - op2: function (root) { + op2: function(root) { root._properties.children.remove(node2); }, - compareToSequential: true + compareToSequential: true, }); }); - it('with a modify and a remove should possible', function () { + it('with a modify and a remove should possible', function() { var node1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.children.insert(node1); }, op1: modifyLeaf, op2: removeFirstNodeInRoot, - compareToSequential: true + compareToSequential: true, }); }); - it('with a remove and a modify should possible', function () { + it('with a remove and a modify should possible', function() { var node1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.children.insert(node1); }, op1: removeFirstNodeInRoot, op2: modifyLeaf, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFIED_AFTER_REMOVE); expect(conflicts[0].path).to.be.equal('children[' + node1.getGuid() + ']'); expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; - } + }, }); }); - it('with two compatible removes should be possible', function () { + it('with two compatible removes should be possible', function() { var node1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.children.insert(node1); }, - op1: function (root) { + op1: function(root) { root._properties.children.remove(node1); }, - op2: function (root) { + op2: function(root) { root._properties.children.remove(node1); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; - } + }, }); }); - it('with two indendent recursive modifies should be possible', function () { + it('with two indendent recursive modifies should be possible', function() { var node1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.children.insert(node1); }, - op1: function (root) { + op1: function(root) { root._properties.children.getAsArray()[0]._properties.stringProperty.value = 'a'; }, - op2: function (root) { + op2: function(root) { root._properties.children.getAsArray()[0]._properties.stringProperty2.value = 'a'; }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.be.empty; - } + }, }); }); - it('with two conflicting recursive modifies should be possible and report a conflict', function () { + it('with two conflicting recursive modifies should be possible and report a conflict', function() { var node1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.children.insert(node1); }, - op1: function (root) { + op1: function(root) { root._properties.children.getAsArray()[0]._properties.stringProperty.value = 'a'; }, - op2: function (root) { + op2: function(root) { root._properties.children.getAsArray()[0]._properties.stringProperty.value = 'a'; }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('children[' + node1.getGuid() + '].stringProperty'); - } + }, }); }); - it('with modify followed by remove+insert should work', function () { + it('with modify followed by remove+insert should work', function() { var node1; testRebasing({ - prepare: function (root) { + prepare: function(root) { node1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); root._properties.children.insert(node1); }, op1: modifyLeaf, - op2: function (root) { + op2: function(root) { var node2 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); node2._properties.guid.value = node1._properties.guid.value; @@ -740,23 +735,23 @@ describe('SetProperty', function () { root._properties.children.insert(node2); }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.REMOVE_AFTER_MODIFY); expect(conflicts[0].path).to.be.equal('children[' + node1.getGuid() + ']'); expect(changeSet['set'].children).to.have.all.keys('remove', 'insert'); - } + }, }); }); - it('with remove+insert followed by modify should report conflict', function () { + it('with remove+insert followed by modify should report conflict', function() { var node1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.children.insert(node1); }, - op1: function (root) { + op1: function(root) { var node2 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); node2._properties.guid.value = node1._properties.guid.value; @@ -765,15 +760,15 @@ describe('SetProperty', function () { }, op2: modifyLeaf, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFICATION_AFTER_REMOVE_INSERT); expect(conflicts[0].path).to.be.equal('children[' + node1.getGuid() + ']'); - } + }, }); }); - it('with remove+insert followed by remove+insert should report conflict', function () { + it('with remove+insert followed by remove+insert should report conflict', function() { var node = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var node1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var node2 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); @@ -781,45 +776,45 @@ describe('SetProperty', function () { node1._properties.guid.value = node._properties.guid.value; node2._properties.guid.value = node._properties.guid.value; testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.children.insert(node); }, - op1: function (root) { + op1: function(root) { root._properties.children.set(node1); }, - op2: function (root) { + op2: function(root) { root._properties.children.set(node2); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('children[' + node.getGuid() + ']'); - } + }, }); }); - it('with conflicting inserts should report conflict', function () { + it('with conflicting inserts should report conflict', function() { var node1 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); var node2 = PropertyFactory.create('autodesk.tests:TestPropertyID-1.0.0'); node2._properties.guid.value = node1._properties.guid.value; testRebasing({ - prepare: function (root) { + prepare: function(root) { }, - op1: function (root) { + op1: function(root) { root._properties.children.insert(node1); }, - op2: function (root) { + op2: function(root) { root._properties.children.insert(node2); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.INSERTED_ENTRY_WITH_SAME_KEY); expect(conflicts[0].path).to.be.equal('children[' + node1.getGuid() + ']'); - } + }, }); }); }); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/stringProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/stringProperty.spec.js index 56de14821c75..54843f5f50cb 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/stringProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/stringProperty.spec.js @@ -2,30 +2,30 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /** * @fileoverview In this file, we will test the string property * object described in /src/properties/stringProperty.js */ +const { ChangeSet } = require('@fluid-experimental/property-changeset'); +const { MSG } = require('@fluid-experimental/property-common').constants; const _ = require('lodash'); const { PropertyFactory } = require('../..'); const { BaseProperty } = require('../..'); -const { ChangeSet } = require('@fluid-experimental/property-changeset'); -const { MSG } = require('@fluid-experimental/property-common').constants; const deepCopy = _.cloneDeep; -describe('StringProperty', function () { +describe('StringProperty', function() { var changeSetWithEntries, removalChangeSet; var myStringProp; - before(function () { + before(function() { // Register a template with a set property for the tests var SimpleStringTestPropertyTemplate = { typeid: 'autodesk.tests:SimpleStringTestProperty-1.0.0', properties: [ - { id: 'stringProperty', typeid: 'String' } - ] + { id: 'stringProperty', typeid: 'String' }, + ], }; PropertyFactory._reregister(SimpleStringTestPropertyTemplate); @@ -33,37 +33,34 @@ describe('StringProperty', function () { }); // Inserts a char into the string - var insertText = function (stringProp) { + var insertText = function(stringProp) { stringProp.insertRange(0, 'x'); }; // Removes the first char from the string - var removeText = function (stringProp) { + var removeText = function(stringProp) { stringProp.removeRange(0, 1); }; // Modifies the text - var modifyText = function (stringProp) { + var modifyText = function(stringProp) { stringProp.setRange(0, 'y'); }; // set the text to a given string - var setText = function (stringProp) { + var setText = function(stringProp) { stringProp.value = 's'; }; - - - describe('Testing creation, assignment and serialization', function () { - - it('should be empty at the beginning', function () { + describe('Testing creation, assignment and serialization', function() { + it('should be empty at the beginning', function() { expect(myStringProp.value).to.equal(''); expect(myStringProp.getValue()).to.equal(''); expect(myStringProp.serialize({ 'dirtyOnly': true })).to.be.empty; expect(myStringProp.serialize({ 'dirtyOnly': false })).to.equal(''); }); - it('should be possible to insert into the string', function () { + it('should be possible to insert into the string', function() { // Text insertion myStringProp.insertRange(0, 'abef'); expect(myStringProp.value).to.equal('abef'); @@ -79,7 +76,7 @@ describe('StringProperty', function () { CS.insert[0][1] === 'abcdef').to.be.ok; }); - it('Should handle removals correctly', function () { + it('Should handle removals correctly', function() { myStringProp.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY); myStringProp.removeRange(3, 2); expect(myStringProp.value).to.equal('abcf'); @@ -90,7 +87,7 @@ describe('StringProperty', function () { expect(removalChangeSet.remove[0]).to.deep.equal([3, 2]); }); - it('Should support deserialization', function () { + it('Should support deserialization', function() { var deserializedNode = PropertyFactory.create('String'); var deserializedChanges1 = deserializedNode.deserialize(changeSetWithEntries); expect(deserializedChanges1).to.deep.equal(changeSetWithEntries); @@ -104,16 +101,15 @@ describe('StringProperty', function () { deserializedNode.deserialize(changeSetWithEntries); // refill var deserializedChanges4 = deserializedNode.deserialize(''); expect(deserializedChanges4).to.deep.equal(''); - }); - it('inserting at a bad position should throw an exception', function () { - expect(function () { + it('inserting at a bad position should throw an exception', function() { + expect(function() { myStringProp.insertRange(2242, 'x'); }).to.throw(); }); - it('insert after set should work', function () { + it('insert after set should work', function() { var testString = PropertyFactory.create('String'); testString.value = 'A'; testString.insertRange(0, 'B'); @@ -122,7 +118,7 @@ describe('StringProperty', function () { expect(testString.serialize({ 'dirtyOnly': true })).to.equal('BA'); }); - it('remove after set should work', function () { + it('remove after set should work', function() { var testString = PropertyFactory.create('String'); testString.value = 'ABCD'; testString.removeRange(1, 2); @@ -131,7 +127,7 @@ describe('StringProperty', function () { expect(testString.serialize({ 'dirtyOnly': true })).to.equal('AD'); }); - it('modify after set should work', function () { + it('modify after set should work', function() { var testString = PropertyFactory.create('String'); testString.value = 'ABCD'; testString.setRange(1, 'XY'); @@ -140,7 +136,7 @@ describe('StringProperty', function () { expect(testString.serialize({ 'dirtyOnly': true })).to.equal('AXYD'); }); - it('set must stay a set', function () { + it('set must stay a set', function() { var testString = PropertyFactory.create('String'); testString.value = 'ABCD'; expect(testString.serialize({ 'dirtyOnly': true })).to.equal('ABCD'); @@ -151,32 +147,32 @@ describe('StringProperty', function () { expect(testString.serialize({ 'dirtyOnly': true })).to.equal('XYZ'); }); - it('.get should return a single letter', function () { + it('.get should return a single letter', function() { var testString = PropertyFactory.create('String'); testString.value = 'ABCD'; expect(testString.get(2)).to.equal('C'); }); - it('.getFullTypeid should return a string of the typeid', function () { + it('.getFullTypeid should return a string of the typeid', function() { var testString = PropertyFactory.create('String'); expect(testString.getFullTypeid()).to.equal('String'); }); - it('.insert should insert a string', function () { + it('.insert should insert a string', function() { var testString = PropertyFactory.create('String'); testString.setValue('AAAAA'); testString.insert(1, 'BB'); expect(testString.getValue()).to.equal('ABBAAAA'); }); - it('.insertRange should insert a string', function () { + it('.insertRange should insert a string', function() { var testString = PropertyFactory.create('String'); testString.setValue('AAAAA'); testString.insertRange(1, 'BB'); expect(testString.getValue()).to.equal('ABBAAAA'); }); - it('Should report dirtiness correctly when introducing a modification in certain order', function () { + it('Should report dirtiness correctly when introducing a modification in certain order', function() { testString = PropertyFactory.create('String'); let newValue = "test"; const node = PropertyFactory.create('NodeProperty'); @@ -193,21 +189,21 @@ describe('StringProperty', function () { expect(Object.keys(node._serialize(true, false, 2))).to.have.length(1); }); - it('.insertRange should also accept an array with a single string', function () { + it('.insertRange should also accept an array with a single string', function() { var testString = PropertyFactory.create('String'); testString.setValue('AAAAA'); testString.insertRange(1, ['BC']); expect(testString.getValue()).to.equal('ABCAAAA'); }); - it('.insertRange should join an array with more than one string', function () { + it('.insertRange should join an array with more than one string', function() { var testString = PropertyFactory.create('String'); testString.setValue('AAAAA'); testString.insertRange(1, ['B', 'C', 'D']); expect(testString.getValue()).to.equal('ABCDAAAA'); }); - it('.push should add a string to the end of the original string and return the length of the string', function () { + it('.push should add a string to the end of the original string and return the length of the string', function() { var testString = PropertyFactory.create('String'); testString.setValue('AAAAA'); testString.push('BB'); @@ -216,8 +212,8 @@ describe('StringProperty', function () { }); }); - describe('inherited API methods', function () { - it('.clear should remove all values from the string', function () { + describe('inherited API methods', function() { + it('.clear should remove all values from the string', function() { var testString = PropertyFactory.create('String'); testString.setValue('AAAAA'); expect(testString.getValue()).to.equal('AAAAA'); @@ -225,33 +221,33 @@ describe('StringProperty', function () { expect(testString.getValue()).to.equal(''); }); - it('.getEntriesReadOnly should return a string', function () { + it('.getEntriesReadOnly should return a string', function() { var testString = PropertyFactory.create('String'); testString.setValue('AAAAA'); expect(testString.getEntriesReadOnly()).to.equal('AAAAA'); }); - it('.getIds should return an array of string ids', function () { + it('.getIds should return an array of string ids', function() { var testString = PropertyFactory.create('String'); testString.setValue('AAAAA'); expect(testString.getIds()).to.deep.equal(['0', '1', '2', '3', '4']); }); - it('.getLength should return the length of the string', function () { + it('.getLength should return the length of the string', function() { var testString = PropertyFactory.create('String'); expect(testString.getLength()).to.equal(0); testString.setValue('AAAAA'); expect(testString.getLength()).to.equal(5); }); - it('.pop should remove the last letter', function () { + it('.pop should remove the last letter', function() { var testString = PropertyFactory.create('String'); testString.setValue('ABCDE'); testString.pop(); expect(testString.getValue()).to.equal('ABCD'); }); - it('.remove should remove a single letter', function () { + it('.remove should remove a single letter', function() { var testString = PropertyFactory.create('String'); testString.setValue('ABCDE'); testString.remove(2); @@ -259,7 +255,7 @@ describe('StringProperty', function () { expect(testString.remove(1)).to.equal('B'); }); - it('removeRange should remove a range of letters', function () { + it('removeRange should remove a range of letters', function() { var testString = PropertyFactory.create('String'); testString.setValue('ABCDEFG'); testString.removeRange(1, 2); @@ -267,60 +263,60 @@ describe('StringProperty', function () { expect(testString.removeRange(2, 3)).to.equal('EFG'); }); - it('@regression removeRange should clear a value longer than the special value "setAsLiteral"', function () { + it('@regression removeRange should clear a value longer than the special value "setAsLiteral"', function() { var testString = PropertyFactory.create('String'); testString.setValue('AAAAAAAAAAAAAAAAAA'); testString.removeRange(0, testString.getValue().length); expect(testString.getValue()).to.equal(''); }); - it('set should set a single character', function () { + it('set should set a single character', function() { var testString = PropertyFactory.create('String'); testString.setValue('ABCDEFG'); testString.set(3, 'x'); expect(testString.getValue()).to.equal('ABCxEFG'); }); - it('set should not allow setting more than one character', function () { + it('set should not allow setting more than one character', function() { var testString = PropertyFactory.create('String'); testString.setValue('ABCDEFG'); - expect(function () { testString.set(0, 'ab'); }).to.throw(MSG.STRING_SET_ONE_CHAR); + expect(function() { testString.set(0, 'ab'); }).to.throw(MSG.STRING_SET_ONE_CHAR); }); - it('set should throw if in_offset is not an integer', function () { + it('set should throw if in_offset is not an integer', function() { var testString = PropertyFactory.create('String'); testString.setValue('ABCDEFG'); - expect(function () { testString.set('test', 'a'); }).to.throw(MSG.STRING_SET_NEEDS_INDEX); + expect(function() { testString.set('test', 'a'); }).to.throw(MSG.STRING_SET_NEEDS_INDEX); }); - it('setRange should replace a range of letters', function () { + it('setRange should replace a range of letters', function() { var testString = PropertyFactory.create('String'); testString.setValue('ABCDEFG'); testString.setRange(3, 'xx'); expect(testString.getValue()).to.equal('ABCxxFG'); }); - it('setRange should throw if trying to set out of range', function () { + it('setRange should throw if trying to set out of range', function() { var testString = PropertyFactory.create('String'); testString.setValue('ABCDEFG'); - var fn = function () { + var fn = function() { testString.setRange(5, 'xxxxxx'); }; expect(fn).to.throw(); }); - it('setRange should throw if in_offset is not an integer', function () { + it('setRange should throw if in_offset is not an integer', function() { var testString = PropertyFactory.create('String'); testString.setValue('ABCDEFG'); - var fn = function () { + var fn = function() { testString.setRange('test', 'xx'); }; expect(fn).to.throw(MSG.NOT_NUMBER); }); - it('shift should remove a single letter at the beginning of the string', function () { + it('shift should remove a single letter at the beginning of the string', function() { var testString = PropertyFactory.create('String'); testString.setValue('ABCDEFG'); testString.shift(); @@ -328,7 +324,7 @@ describe('StringProperty', function () { expect(testString.shift()).to.equal('B'); }); - it('unshift should add letters at the beginning of a string and return the length of the string', function () { + it('unshift should add letters at the beginning of a string and return the length of the string', function() { var testString = PropertyFactory.create('String'); testString.setValue('ABC'); testString.unshift('DE'); @@ -337,48 +333,47 @@ describe('StringProperty', function () { }); }); - describe('change set specification should be met', function () { - it('Should handle inserts correctly', function () { + describe('change set specification should be met', function() { + it('Should handle inserts correctly', function() { var t = PropertyFactory.create('String'); t.value = 'test'; t.cleanDirty(); t.insert(2, '_test_'); expect(t.serialize({ 'dirtyOnly': true })).to.deep.equal( { - 'insert': [[2, '_test_']] - } + 'insert': [[2, '_test_']], + }, ); }); - it('Should handle push correctly', function () { + it('Should handle push correctly', function() { var t = PropertyFactory.create('String'); t.value = 'test'; t.cleanDirty(); t.push('_test_'); expect(t.serialize({ 'dirtyOnly': true })).to.deep.equal( { - 'insert': [[4, '_test_']] - } + 'insert': [[4, '_test_']], + }, ); }); - it('Should handle modifies correctly', function () { + it('Should handle modifies correctly', function() { var t = PropertyFactory.create('String'); t.value = 'test'; t.cleanDirty(); t.setRange(1, '_x_'); expect(t.serialize({ 'dirtyOnly': true })).to.deep.equal( { - 'modify': [[1, '_x_']] - } + 'modify': [[1, '_x_']], + }, ); }); }); - - describe('squashing', function () { + describe('squashing', function() { // Helper function to test the squashing for different containers - var innerTestChangeSetSquashing = function (io_testProperty, io_stringProperty, + var innerTestChangeSetSquashing = function(io_testProperty, io_stringProperty, io_initialChangeset, in_options, in_collection) { var squashedChangeset = new ChangeSet(); io_testProperty.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY | @@ -410,8 +405,7 @@ describe('StringProperty', function () { // Optionally, a a callback which controls the initial state before the squashing can // be given as first parameter // - var testChangeSetSquashing = function (in_options) { - + var testChangeSetSquashing = function(in_options) { var testProperty = PropertyFactory.create('autodesk.tests:SimpleStringTestProperty-1.0.0'); var nodeTestProperty = PropertyFactory.create('NodeProperty'); var stringInNodeProperty = PropertyFactory.create('String'); @@ -478,129 +472,126 @@ describe('StringProperty', function () { } expect(mapInitialChangesetString).to.deep.equal(mapTestProperty.serialize().insert.String.stringProperty); } - }; - it('should work for multiple independent inserts', function () { + it('should work for multiple independent inserts', function() { testChangeSetSquashing({ callbacks: [insertText, insertText, insertText] }); }); - it('should work for inserts followed by removes', function () { + it('should work for inserts followed by removes', function() { testChangeSetSquashing({ callbacks: [insertText, insertText, removeText, removeText], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('should work for mixed modifies and inserts', function () { + it('should work for mixed modifies and inserts', function() { testChangeSetSquashing({ - callbacks: [insertText, modifyText, insertText, modifyText] + callbacks: [insertText, modifyText, insertText, modifyText], }); }); - it('an insert, modify and a remove should give an empty changeset', function () { + it('an insert, modify and a remove should give an empty changeset', function() { testChangeSetSquashing({ callbacks: [insertText, modifyText, removeText], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('work for modifies after an already existing insert', function () { + it('work for modifies after an already existing insert', function() { testChangeSetSquashing({ pre: insertText, - callbacks: [modifyText, modifyText] + callbacks: [modifyText, modifyText], }); }); - it('of modify and remove after an already existing insert should work', function () { + it('of modify and remove after an already existing insert should work', function() { testChangeSetSquashing({ pre: insertText, callbacks: [modifyText, removeText], - post: function (changeset) { + post: function(changeset) { expect(changeset.String.stringProperty).to.have.all.keys('remove'); - } + }, }); }); - it('modify after set should work', function () { + it('modify after set should work', function() { testChangeSetSquashing({ callbacks: [setText, modifyText], - post: function (changeset) { + post: function(changeset) { expect(changeset.String.stringProperty).to.equal('y'); - } + }, }); }); - it('set after pre-insert and insert should work', function () { + it('set after pre-insert and insert should work', function() { testChangeSetSquashing({ pre: insertText, callbacks: [insertText, modifyText, setText], - post: function (changeset) { + post: function(changeset) { expect(changeset.String.stringProperty).to.equal('s'); - } + }, }); }); - it('insert after set should work', function () { + it('insert after set should work', function() { testChangeSetSquashing({ callbacks: [setText, insertText], - post: function (changeset) { + post: function(changeset) { expect(changeset.String.stringProperty).to.equal('xs'); - } + }, }); }); - it('insert, set, insert/modify should work', function () { + it('insert, set, insert/modify should work', function() { testChangeSetSquashing({ callbacks: [insertText, setText, insertText, modifyText], - post: function (changeset) { + post: function(changeset) { expect(changeset.String.stringProperty).to.equal('ys'); - } + }, }); }); - it('insert, set, insert/modify, set should work', function () { + it('insert, set, insert/modify, set should work', function() { testChangeSetSquashing({ callbacks: [insertText, setText, insertText, modifyText, setText], - post: function (changeset) { + post: function(changeset) { expect(changeset.String.stringProperty).to.equal('s'); - } + }, }); }); }); - - describe('Rebasing', function () { - - var createPropertyForRebaseTestByTemplate = function () { + describe('Rebasing', function() { + var createPropertyForRebaseTestByTemplate = function() { return PropertyFactory.create('autodesk.tests:SimpleStringTestProperty-1.0.0'); }; - var createNodePropertyForRebase = function () { + var createNodePropertyForRebase = function() { var nodeTestProperty = PropertyFactory.create('NodeProperty'); var stringInNodeProperty = PropertyFactory.create('String'); nodeTestProperty.insert('stringProperty', stringInNodeProperty); return nodeTestProperty; }; - var createMapPropertyForRebase = function () { + var createMapPropertyForRebase = function() { var mapTestProperty = PropertyFactory.create('map<>'); var stringInNodeProperty = PropertyFactory.create('String'); mapTestProperty.insert('stringProperty', stringInNodeProperty); return mapTestProperty; }; - var getStringPropertyFromNode = function (in_testProperty) { + var getStringPropertyFromNode = function(in_testProperty) { return in_testProperty._properties.stringProperty; }; - var getStringPropertyFromMap = function (in_testProperty) { + var getStringPropertyFromMap = function(in_testProperty) { return in_testProperty.get('stringProperty'); }; - var testRebasingInner = function (in_creator, in_getInnerProperty, in_options, in_isCollection) { + var testRebasingInner = function(in_creator, in_getInnerProperty, in_options, in_isCollection) { // Prepare the initial state var baseProperty1 = in_creator(); if (in_options.prepare) { @@ -685,235 +676,234 @@ describe('StringProperty', function () { } }; - var testRebasing = function (in_options) { + var testRebasing = function(in_options) { testRebasingInner(createPropertyForRebaseTestByTemplate, getStringPropertyFromNode, in_options); testRebasingInner(createNodePropertyForRebase, getStringPropertyFromNode, in_options, true); testRebasingInner(createMapPropertyForRebase, getStringPropertyFromMap, in_options, true); }; - it('with a NOP should be possible', function () { + it('with a NOP should be possible', function() { testRebasing({ op2: insertText, - compareToSequential: true + compareToSequential: true, }); }); - it('with independent inserts should be possible', function () { + it('with independent inserts should be possible', function() { testRebasing({ op1: insertText, op2: insertText, - compareToSequential: true + compareToSequential: true, }); }); - it('with independent removes should be possible', function () { + it('with independent removes should be possible', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { insertText(root); insertText(root); }, - op1: function (root) { + op1: function(root) { root.removeRange(1, 1); }, - op2: function (root) { + op2: function(root) { root.removeRange(0, 1); }, - compareToSequential: true + compareToSequential: true, }); }); - it('with a modify and a remove should possible', function () { + it('with a modify and a remove should possible', function() { testRebasing({ prepare: insertText, op1: modifyText, op2: removeText, - compareToSequential: true + compareToSequential: true, }); }); - it('with a remove and a modify should possible', function () { - + it('with a remove and a modify should possible', function() { testRebasing({ prepare: insertText, op1: removeText, op2: modifyText, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFIED_AFTER_REMOVE); expect(conflicts[0].path).to.be.equal('stringProperty'); - } + }, }); }); - it('with two compatible removes should be possible', function () { + it('with two compatible removes should be possible', function() { testRebasing({ prepare: insertText, op1: removeText, op2: removeText, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; - } + }, }); }); - it('with two independent modifies should be possible', function () { + it('with two independent modifies should be possible', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root.insertRange(0, 'ab'); }, op1: modifyText, - op2: function (root) { + op2: function(root) { root.setRange(1, 'z'); }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.be.empty; - } + }, }); }); // TODO: test with the same value - it('with two conflicting modifies should be possible and report a conflict', function () { + it('with two conflicting modifies should be possible and report a conflict', function() { testRebasing({ prepare: insertText, - op1: function (stringProp) { + op1: function(stringProp) { stringProp.setRange(0, 'j'); }, op2: modifyText, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(changeSet.String.stringProperty.modify[0][1]).to.equal('y'); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('stringProperty'); - } + }, }); }); - it('with modify followed by remove+insert should work', function () { + it('with modify followed by remove+insert should work', function() { testRebasing({ prepare: insertText, op1: modifyText, - op2: function (root) { + op2: function(root) { removeText(root); insertText(root); }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.REMOVE_AFTER_MODIFY); expect(conflicts[0].path).to.be.equal('stringProperty'); expect(changeSet.String.stringProperty).to.have.all.keys('remove', 'insert'); - } + }, }); }); - it('with remove + insert followed by modify should report conflict', function () { + it('with remove + insert followed by modify should report conflict', function() { testRebasing({ prepare: insertText, - op1: function (root) { + op1: function(root) { removeText(root); insertText(root); }, op2: modifyText, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFIED_AFTER_REMOVE); expect(conflicts[0].path).to.be.equal('stringProperty'); - } + }, }); }); - it('with conflicting inserts should report conflict', function () { + it('with conflicting inserts should report conflict', function() { testRebasing({ prepare: insertText, op1: insertText, op2: insertText, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.INSERTED_ENTRY_WITH_SAME_KEY); expect(conflicts[0].path).to.be.equal('stringProperty'); - } + }, }); }); - it('with conflicting remove and insert should keep the insert and move it to the correct position', function () { + it('with conflicting remove and insert should keep the insert and move it to the correct position', function() { testRebasing({ - prepare: function (p) { + prepare: function(p) { p.insertRange(0, '0123456'); }, - op1: function (p) { + op1: function(p) { p.removeRange(2, 5); }, - op2: function (p) { + op2: function(p) { p.insertRange(5, 't'); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(0); expect(changeSet).to.deep.equal({ - 'String': { stringProperty: { insert: [[2, 't']] } } + 'String': { stringProperty: { insert: [[2, 't']] } }, }); - } + }, }); }); - it('with touching remove and insert should not report conflict and keep them', function () { + it('with touching remove and insert should not report conflict and keep them', function() { testRebasing({ - prepare: function (p) { + prepare: function(p) { p.insertRange(0, '0123456'); }, - op1: function (p) { + op1: function(p) { p.removeRange(2, 3); }, - op2: function (p) { + op2: function(p) { p.insertRange(5, 'b'); p.insertRange(2, 'a'); }, compareToSequential: false, - checkResult: function (conflicts, rebasedCS2, combinedChangeSet) { + checkResult: function(conflicts, rebasedCS2, combinedChangeSet) { expect(conflicts).to.have.length(0); expect(rebasedCS2).to.deep.equal({ 'String': { stringProperty: { insert: [[2, 'ab']] } } }); expect(combinedChangeSet).to.deep.equal({ 'String': { 'stringProperty': '01ab56' } }); - } + }, }); }); - it('with conflicting set and insert should report a conflict', function () { + it('with conflicting set and insert should report a conflict', function() { testRebasing({ prepare: insertText, op1: setText, op2: insertText, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('stringProperty'); expect(changeSet.String.stringProperty).to.be.equal('s'); - } + }, }); }); - it('with conflicting insert and set should report a conflict', function () { + it('with conflicting insert and set should report a conflict', function() { testRebasing({ prepare: insertText, op1: insertText, op2: setText, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('stringProperty'); expect(changeSet.String.stringProperty).to.be.equal('s'); - } + }, }); }); - it('should correctly handle boundary cases', function () { - var testChangeSet = function (in_CS, in_CS2) { + it('should correctly handle boundary cases', function() { + var testChangeSet = function(in_CS, in_CS2) { var root = PropertyFactory.create('NodeProperty'); var initialString = PropertyFactory.create('String'); root.insert('str', initialString); @@ -939,15 +929,14 @@ describe('StringProperty', function () { expect(testChangeSet(CS2.getSerializedChangeSet(), rebasedCS1)).to.equal('AA--AA'); expect(testChangeSet(CS1.getSerializedChangeSet(), rebasedCS2)).to.equal('AA--AA'); }); - }); - it('field "length" in schema should be ignored', function () { + it('field "length" in schema should be ignored', function() { var SchemaStringWithLength = { typeid: 'autodesk.tests:SchemaStringWithLength-1.0.0', properties: [ - { id: 'stringProperty', typeid: 'String', length: 4 } - ] + { id: 'stringProperty', typeid: 'String', length: 4 }, + ], }; PropertyFactory.register(SchemaStringWithLength); @@ -955,18 +944,16 @@ describe('StringProperty', function () { expect(prop.get('stringProperty').getValue()).to.equal(''); }); - it.skip('@bugfix field "length" not a number in schema should be ignored', function () { + it.skip('@bugfix field "length" not a number in schema should be ignored', function() { var SchemaStringWithStringLength = { typeid: 'autodesk.tests:SchemaStringWithStringLength-1.0.0', properties: [ - { id: 'stringProperty', typeid: 'String', length: '4' } - ] + { id: 'stringProperty', typeid: 'String', length: '4' }, + ], }; PropertyFactory.register(SchemaStringWithStringLength); var prop = PropertyFactory.create(SchemaStringWithStringLength.typeid); expect(prop.get('stringProperty').getValue()).to.equal(''); }); - - }); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/uint64Property.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/uint64Property.spec.js index bd4d9687f746..0b648db9245e 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/uint64Property.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/uint64Property.spec.js @@ -2,19 +2,18 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /** * @fileoverview In this file, we will test the functions of 64 bit Uinteger properties * described in /src/shared/property_sets/properties/int_property.js */ -const { PropertyFactory } = require('../..'); -const { Uint64 } = require('@fluid-experimental/property-common'); const { MSG } = require('@fluid-experimental/property-common').constants; +const { Uint64 } = require('@fluid-experimental/property-common'); +const { PropertyFactory } = require('../..'); -describe('Test Uint64Property', function () { - - it('should correctly setValue when passed a number', function () { +describe('Test Uint64Property', function() { + it('should correctly setValue when passed a number', function() { const prop = PropertyFactory.create('Uint64'); const value = 123; prop.setValue(value); @@ -23,13 +22,13 @@ describe('Test Uint64Property', function () { expect(prop.toString()).to.equal(value.toString()); }); - it('should throw when setValue is passed a negative number', function () { + it('should throw when setValue is passed a negative number', function() { const prop = PropertyFactory.create('Uint64'); const value = -123; expect(() => { prop.setValue(value); }).to.throw(); }); - it('should correctly setValue when passed a large number ( larger than 2^53)', function () { + it('should correctly setValue when passed a large number ( larger than 2^53)', function() { const prop = PropertyFactory.create('Int64'); const value = Math.pow(2, 64) - 1000; prop.setValue(value); @@ -38,7 +37,7 @@ describe('Test Uint64Property', function () { expect(prop.toString()).to.equal(value.toString()); }); - it('should correctly setValue when passed a string', function () { + it('should correctly setValue when passed a string', function() { const prop = PropertyFactory.create('Uint64'); const value = '1234567890'; prop.setValue(value); @@ -47,12 +46,12 @@ describe('Test Uint64Property', function () { expect(prop.toString()).to.equal('1234567890'); }); - it('should throw error when passed a string with non numbers', function () { + it('should throw error when passed a string with non numbers', function() { const prop = PropertyFactory.create('Uint64'); expect(prop.setValue.bind(prop, 'error')).to.throw(MSG.CANNOT_PARSE_INVALID_CHARACTERS + 'error'); }); - it('should correctly convert to string', function () { + it('should correctly convert to string', function() { const prop = PropertyFactory.create('Uint64'); prop.value = new Uint64(845094001, 1810905006); @@ -65,14 +64,14 @@ describe('Test Uint64Property', function () { expect(prop.toString()).to.be.equal('18446744073709551615'); }); - it('should work correctly when explicitly set fromString', function () { + it('should work correctly when explicitly set fromString', function() { const prop = PropertyFactory.create('Uint64'); - expect(function () { prop.fromString('-1'); }).to.throw(); - expect(function () { prop.fromString('abcd'); }).to.throw(); + expect(function() { prop.fromString('-1'); }).to.throw(); + expect(function() { prop.fromString('abcd'); }).to.throw(); - expect(function () { prop.fromString('22545455', 37); }).to.throw(); - expect(function () { prop.fromString('22545455', 1); }).to.throw(); + expect(function() { prop.fromString('22545455', 37); }).to.throw(); + expect(function() { prop.fromString('22545455', 1); }).to.throw(); prop.fromString('1a2b3c4d5e6f', 16); expect(prop.toString(16)).to.be.equal('1a2b3c4d5e6f'); @@ -82,7 +81,7 @@ describe('Test Uint64Property', function () { expect(prop.toString(2)).to.be.equal(maxUintString); }); - it('should correctly dirty on set', function () { + it('should correctly dirty on set', function() { const prop = PropertyFactory.create('Uint64'); prop.cleanDirty(); expect(prop.isDirty()).to.be.false; diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/valueMapProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/valueMapProperty.spec.js index 7120bd50385b..1a5e4c769e3f 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/valueMapProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/valueMapProperty.spec.js @@ -3,27 +3,26 @@ * Licensed under the MIT License. */ /* globals describe */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /** * @fileoverview In this file, we will test the map property * object described in /src/properties/mapProperty.js */ +const { ChangeSet } = require('@fluid-experimental/property-changeset'); const { PropertyFactory } = require('../..'); const { BaseProperty } = require('../..'); -const { ChangeSet } = require('@fluid-experimental/property-changeset') -describe('ValueMapProperty', function () { +describe('ValueMapProperty', function() { var myNode, Uint32Map; - before(function () { - + before(function() { // Register a template with a set property for the tests var TestPropertyTemplate = { typeid: 'autodesk.tests:ValueMapTestPropertyID-1.0.0', inherits: ['NamedProperty'], properties: [ - { id: 'Uint32Map', typeid: 'Uint32', context: 'map' } - ] + { id: 'Uint32Map', typeid: 'Uint32', context: 'map' }, + ], }; // Register a template with a set property for the tests @@ -40,25 +39,24 @@ describe('ValueMapProperty', function () { { id: 'Float64Map', typeid: 'Float64', context: 'map' }, { id: 'Float32Map', typeid: 'Float32', context: 'map' }, { id: 'StringMap', typeid: 'String', context: 'map' }, - { id: 'BoolMap', typeid: 'Bool', context: 'map' } - ] + { id: 'BoolMap', typeid: 'Bool', context: 'map' }, + ], }; PropertyFactory._reregister(TestPropertyTemplate); PropertyFactory._reregister(AllTypesTestPropertyTemplate); myNode = PropertyFactory.create('autodesk.tests:ValueMapTestPropertyID-1.0.0'); Uint32Map = myNode._properties.Uint32Map; - }); // Helper functions for the test cases var keyCounter = 0; - var resetKeyCounter = function () { + var resetKeyCounter = function() { keyCounter = 0; }; // Inserts a node with a given key (a new one is generated when undefined) - var insertEntryInRootWithKey = function (key, root) { + var insertEntryInRootWithKey = function(key, root) { if (key === undefined) { key = 'node' + keyCounter++; } @@ -66,34 +64,34 @@ describe('ValueMapProperty', function () { }; // Inserts a new node in the root - var insertNodeInRoot = function (root) { + var insertNodeInRoot = function(root) { insertEntryInRootWithKey(undefined, root); }; // Returns a functor that will insert a node with a constant key - var insertEntryInRootWithUnqiueKey = function () { + var insertEntryInRootWithUnqiueKey = function() { var key = 'node' + keyCounter++; return insertEntryInRootWithKey.bind(undefined, key); }; // Removes the first node from the root - var removeFirstNodeInRoot = function (root) { + var removeFirstNodeInRoot = function(root) { var firstKey = root._properties.Uint32Map.getIds()[0]; root._properties.Uint32Map.remove(firstKey); }; // Modifies the first node - var modifyEntry = function (root) { + var modifyEntry = function(root) { var firstKey = root._properties.Uint32Map.getIds()[0]; root._properties.Uint32Map.set(firstKey, root._properties.Uint32Map.get(firstKey) + 1); }; - describe('Inherited API Methods', function () { + describe('Inherited API Methods', function() { var newMap; - before(function () { + before(function() { newMap = PropertyFactory.create('Int32', 'map'); }); - it('.clear should work to remove all entries in the map', function () { + it('.clear should work to remove all entries in the map', function() { newMap.insert('one', 1); newMap.insert('two', 2); expect(newMap.getValues()).to.deep.equal({ 'one': 1, 'two': 2 }); @@ -101,62 +99,62 @@ describe('ValueMapProperty', function () { expect(newMap.getValues()).to.deep.equal({}); }); - it('.getAsArray should return an array of map values', function () { + it('.getAsArray should return an array of map values', function() { newMap.insert('one', 1); newMap.insert('two', 2); expect(newMap.getAsArray()).to.deep.equal([1, 2]); }); - it('getEntriesReadOnly should work', function () { + it('getEntriesReadOnly should work', function() { newMap.insert('one', 1); newMap.insert('two', 2); expect(newMap.getEntriesReadOnly()).to.deep.equal({ 'one': 1, 'two': 2 }); }); - it('.getFullTypeid should return a string of the typeid with or without collection', function () { + it('.getFullTypeid should return a string of the typeid with or without collection', function() { expect(newMap.getFullTypeid()).to.equal('map'); expect(newMap.getFullTypeid(true)).to.equal('Int32'); }); - it('.getIds should return an array of map keys', function () { + it('.getIds should return an array of map keys', function() { newMap.insert('one', 1); newMap.insert('two', 2); expect(newMap.getIds()).to.deep.equal(['one', 'two']); }); - it('.getValues should return an object', function () { + it('.getValues should return an object', function() { newMap.insert('one', 1); newMap.insert('two', 2); expect(newMap.getValues()).to.deep.equal({ 'one': 1, 'two': 2 }); }); - it('.has should return a boolean', function () { + it('.has should return a boolean', function() { newMap.insert('one', 1); newMap.insert('two', 2); expect(newMap.has('two')).to.equal(true); expect(newMap.has('three')).to.equal(false); }); - it('.setValues should work to set multiple values', function () { + it('.setValues should work to set multiple values', function() { newMap.setValues({ 'first': 11, 'second': 22, 'third': 33 }); expect(newMap.get('first')).to.equal(11); expect(newMap.get('third')).to.equal(33); }); - afterEach(function () { + afterEach(function() { newMap.clear(); }); }); - describe('Testing creation, assignment and serialization', function () { - it('should be empty at the beginning', function () { + describe('Testing creation, assignment and serialization', function() { + it('should be empty at the beginning', function() { expect(Uint32Map.getAsArray()).to.be.empty; expect(Uint32Map.getEntriesReadOnly()).to.be.empty; expect(ChangeSet.isEmptyChangeSet(Uint32Map.serialize({ 'dirtyOnly': false }))).to.be.ok; expect(ChangeSet.isEmptyChangeSet(Uint32Map.serialize({ 'dirtyOnly': true }))).to.be.ok; }); - it('should be possible to add entries', function () { + it('should be possible to add entries', function() { Uint32Map.insert('value1', 1); expect(Uint32Map.get('value1')).to.equal(1); Uint32Map.insert('value2', 2); @@ -169,11 +167,11 @@ describe('ValueMapProperty', function () { expect(Uint32Map.has('value2')).to.be.ok; expect(Uint32Map.has('value3')).to.be.ok; expect(Uint32Map.serialize()).to.deep.equal({ - insert: { 'value1': 1, 'value2': 2, 'value3': 3 } + insert: { 'value1': 1, 'value2': 2, 'value3': 3 }, }); }); - it('should be possible to remove entries', function () { + it('should be possible to remove entries', function() { Uint32Map.remove('value1'); expect(Uint32Map.has('value1')).to.be.not.ok; Uint32Map.remove('value2'); @@ -183,7 +181,7 @@ describe('ValueMapProperty', function () { expect(ChangeSet.isEmptyChangeSet(Uint32Map.serialize())).to.be.ok; }); - it('a remove followed by an insert should become a modify', function () { + it('a remove followed by an insert should become a modify', function() { Uint32Map.insert('value1', 1); Uint32Map.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY | BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE); @@ -191,13 +189,13 @@ describe('ValueMapProperty', function () { Uint32Map.insert('value1', 2); expect(Uint32Map.serialize({ 'dirtyOnly': true })).to.deep.equal({ - modify: { 'value1': 2 } + modify: { 'value1': 2 }, }); // This should also work for a set operation Uint32Map.set('value1', 3); expect(Uint32Map.serialize({ 'dirtyOnly': true })).to.deep.equal({ - modify: { 'value1': 3 } + modify: { 'value1': 3 }, }); // But setting the same value should give an empty ChangeSet @@ -216,18 +214,17 @@ describe('ValueMapProperty', function () { expect(Uint32Map.serialize({ 'dirtyOnly': true, 'includeRootTypeid': false, - 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE + 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE, })).to.deep.equal({ modify: { 'value1': 2 } }); expect(Uint32Map.serialize({ 'dirtyOnly': true, 'includeRootTypeid': false, - 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY + 'dirtinessType': BaseProperty.MODIFIED_STATE_FLAGS.DIRTY, })).to.deep.equal({ insert: { 'value1': 2 } }); - }); - it('deserialize should work', function () { + it('deserialize should work', function() { var myInitialStateNode = PropertyFactory.create('autodesk.tests:ValueMapTestPropertyID-1.0.0'); myInitialStateNode._properties.Uint32Map.insert('value1', 1); myInitialStateNode._properties.Uint32Map.insert('value2', 2); @@ -247,7 +244,6 @@ describe('ValueMapProperty', function () { myDeserializeNode2.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY | BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE); - myInitialStateNode.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.DIRTY | BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE); myInitialStateNode._properties.Uint32Map.set('value1', 2); @@ -267,15 +263,15 @@ describe('ValueMapProperty', function () { expect(deserializeChanges).to.deep.equal(changesChangeSet); }); - it('inserting the same key twice should throw an exception', function () { + it('inserting the same key twice should throw an exception', function() { var rootNode = PropertyFactory.create('autodesk.tests:ValueMapTestPropertyID-1.0.0'); rootNode._properties.Uint32Map.insert('node1', 1); - expect(function () { + expect(function() { rootNode._properties.Uint32Map.insert('node1', 2); }).to.throw(); }); - it('set should overwrite existing entry', function () { + it('set should overwrite existing entry', function() { var rootNode = PropertyFactory.create('autodesk.tests:ValueMapTestPropertyID-1.0.0'); rootNode._properties.Uint32Map.set('node1', 0); @@ -295,7 +291,7 @@ describe('ValueMapProperty', function () { expect(rootNode.serialize({ 'dirtyOnly': true })['map'].Uint32Map).to.have.all.keys('modify'); }); - it('casting should work as expected', function () { + it('casting should work as expected', function() { var property = PropertyFactory.create('autodesk.tests:AllTypesValueMapTestPropertyID-1.0.0'); property._properties.Uint32Map.set('tooLarge', 1e20); property._properties.Uint32Map.set('negative', -1); @@ -352,11 +348,9 @@ describe('ValueMapProperty', function () { expect(property._properties.BoolMap.get('true')).to.equal(true); expect(property._properties.BoolMap.get('false')).to.equal(false); - - }); - it('prettyPrint should work', function () { + it('prettyPrint should work', function() { var myProp = PropertyFactory.create('autodesk.tests:ValueMapTestPropertyID-1.0.0')._properties.Uint32Map; myProp.insert('value1', 1); myProp.insert('value2', 2); @@ -365,14 +359,14 @@ describe('ValueMapProperty', function () { ' value1: 1\n' + ' value2: 2\n'; var prettyStr = ''; - myProp.prettyPrint(function (str) { + myProp.prettyPrint(function(str) { prettyStr += str + '\n'; }); expect(prettyStr).to.equal(expectedPrettyStr); }); }); - describe('squashing', function () { + describe('squashing', function() { // // Helper function which takes a sequence of callbacks that are suceessively executed // and the changes applied by the callbacks are separately tracked and squashed in a @@ -381,7 +375,7 @@ describe('ValueMapProperty', function () { // Optionally, a a callback which controls the initial state before the squashing can // be given as first parameter // - var testChangeSetSquashing = function (in_options) { + var testChangeSetSquashing = function(in_options) { resetKeyCounter(); var testProperty = PropertyFactory.create('autodesk.tests:ValueMapTestPropertyID-1.0.0'); @@ -413,68 +407,68 @@ describe('ValueMapProperty', function () { expect(initialChangeset.getSerializedChangeSet()).to.deep.equal(testProperty.serialize({ 'dirtyOnly': false })); }; - it('should work for multiple independent inserts', function () { + it('should work for multiple independent inserts', function() { testChangeSetSquashing({ callbacks: [insertNodeInRoot, insertNodeInRoot, insertNodeInRoot] }); }); - it('should work for inserts followed by removes', function () { + it('should work for inserts followed by removes', function() { testChangeSetSquashing({ callbacks: [insertNodeInRoot, insertNodeInRoot, removeFirstNodeInRoot, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('of inserts and modifies should work', function () { + it('of inserts and modifies should work', function() { testChangeSetSquashing({ - callbacks: [insertNodeInRoot, insertNodeInRoot, insertNodeInRoot, modifyEntry, modifyEntry] + callbacks: [insertNodeInRoot, insertNodeInRoot, insertNodeInRoot, modifyEntry, modifyEntry], }); }); - it('an insert, modify and a remove should give an empty changeset', function () { + it('an insert, modify and a remove should give an empty changeset', function() { testChangeSetSquashing({ callbacks: [insertNodeInRoot, modifyEntry, modifyEntry, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset).to.be.empty; - } + }, }); }); - it('should work for modifies after an already existing insert', function () { + it('should work for modifies after an already existing insert', function() { testChangeSetSquashing({ pre: insertNodeInRoot, - callbacks: [modifyEntry, modifyEntry] + callbacks: [modifyEntry, modifyEntry], }); }); - it('of modify and remove after an already existing insert should work', function () { + it('of modify and remove after an already existing insert should work', function() { testChangeSetSquashing({ pre: insertNodeInRoot, callbacks: [modifyEntry, removeFirstNodeInRoot], - post: function (changeset) { + post: function(changeset) { expect(changeset['map'].Uint32Map).to.have.all.keys('remove'); - } + }, }); }); - it('of remove and insert should result in modify', function () { + it('of remove and insert should result in modify', function() { // Create two nodes with the same GUID testChangeSetSquashing({ - pre: function (root) { + pre: function(root) { root._properties.Uint32Map.insert('node1', 1); }, callbacks: [ removeFirstNodeInRoot, - function (root) { + function(root) { root._properties.Uint32Map.insert('node1', 2); - } + }, ], - post: function (changeset) { + post: function(changeset) { expect(changeset['map'].Uint32Map).to.have.all.keys('modify'); - } + }, }); }); }); - describe('Rebasing', function () { - var testRebasing = function (in_options) { + describe('Rebasing', function() { + var testRebasing = function(in_options) { // Prepare the initial state var baseProperty1 = PropertyFactory.create('autodesk.tests:ValueMapTestPropertyID-1.0.0'); if (in_options.prepare) { @@ -533,160 +527,160 @@ describe('ValueMapProperty', function () { } }; - it('with a NOP should be possible', function () { + it('with a NOP should be possible', function() { testRebasing({ op2: insertEntryInRootWithUnqiueKey(), - compareToSequential: true + compareToSequential: true, }); }); - it('with independent inserts should be possible', function () { + it('with independent inserts should be possible', function() { testRebasing({ op1: insertEntryInRootWithUnqiueKey(), op2: insertEntryInRootWithUnqiueKey(), - compareToSequential: true + compareToSequential: true, }); }); - it('with independent removes should be possible', function () { + it('with independent removes should be possible', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.Uint32Map.insert('entry1', 1); root._properties.Uint32Map.insert('entry2', 2); }, - op1: function (root) { + op1: function(root) { root._properties.Uint32Map.remove('entry1'); }, - op2: function (root) { + op2: function(root) { root._properties.Uint32Map.remove('entry2'); }, - compareToSequential: true + compareToSequential: true, }); }); - it('with a modify and a remove should possible', function () { + it('with a modify and a remove should possible', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.Uint32Map.insert('entry1', 1); }, op1: modifyEntry, op2: removeFirstNodeInRoot, - compareToSequential: true + compareToSequential: true, }); }); - it('with a remove and a modify should possible', function () { + it('with a remove and a modify should possible', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.Uint32Map.insert('entry1', 1); }, op1: removeFirstNodeInRoot, op2: modifyEntry, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.ENTRY_MODIFIED_AFTER_REMOVE); expect(conflicts[0].path).to.be.equal('Uint32Map[entry1]'); expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; - } + }, }); }); - it('with two compatible removes should be possible', function () { + it('with two compatible removes should be possible', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.Uint32Map.insert('entry1', 1); }, - op1: function (root) { + op1: function(root) { root._properties.Uint32Map.remove('entry1'); }, - op2: function (root) { + op2: function(root) { root._properties.Uint32Map.remove('entry1'); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(ChangeSet.isEmptyChangeSet(changeSet)).to.be.ok; - } + }, }); }); - it('with two conflicting modifies should be possible and report a conflict', function () { + it('with two conflicting modifies should be possible and report a conflict', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.Uint32Map.insert('entry1', 1); }, - op1: function (root) { + op1: function(root) { root._properties.Uint32Map.set('entry1', 2); }, - op2: function (root) { + op2: function(root) { root._properties.Uint32Map.set('entry1', 3); }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('Uint32Map[entry1]'); - } + }, }); }); - it('with modify followed by remove+insert should be a conflicting set', function () { + it('with modify followed by remove+insert should be a conflicting set', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.Uint32Map.insert('entry1', 1); }, op1: modifyEntry, - op2: function (root) { + op2: function(root) { root._properties.Uint32Map.remove('entry1'); root._properties.Uint32Map.insert('entry1', 2); }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('Uint32Map[entry1]'); - } + }, }); }); - it('with remove+insert followed by modify should be a conflicting set', function () { + it('with remove+insert followed by modify should be a conflicting set', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { root._properties.Uint32Map.insert('entry1', 1); }, - op1: function (root) { + op1: function(root) { root._properties.Uint32Map.remove('entry1'); root._properties.Uint32Map.insert('entry1', 2); }, - op2: function (root) { + op2: function(root) { root._properties.Uint32Map.set('entry1', 3); }, compareToSequential: true, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('Uint32Map[entry1]'); - } + }, }); }); - it('with conflicting inserts should report conflict', function () { + it('with conflicting inserts should report conflict', function() { testRebasing({ - prepare: function (root) { + prepare: function(root) { }, - op1: function (root) { + op1: function(root) { root._properties.Uint32Map.insert('entry1', 1); }, - op2: function (root) { + op2: function(root) { root._properties.Uint32Map.insert('entry1', 2); }, compareToSequential: false, - checkResult: function (conflicts, changeSet) { + checkResult: function(conflicts, changeSet) { expect(changeSet['map'].Uint32Map).to.have.all.keys('modify'); expect(conflicts).to.have.length(1); expect(conflicts[0].type).to.be.equal(ChangeSet.ConflictType.COLLIDING_SET); expect(conflicts[0].path).to.be.equal('Uint32Map[entry1]'); - } + }, }); }); }); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/properties/valueProperty.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/properties/valueProperty.spec.js index 4f2936ecc303..5123f05e6c22 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/properties/valueProperty.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/properties/valueProperty.spec.js @@ -3,38 +3,38 @@ * Licensed under the MIT License. */ /* globals assert */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /** * @fileoverview In this file, we will test ValueProperty * object described in /src/properties/valueProperty.js */ +const { Int64, Uint64 } = require('@fluid-experimental/property-common'); const { ValueProperty } = require('../../properties/valueProperty'); const { PropertyFactory } = require('../..'); -const { Int64, Uint64 } = require('@fluid-experimental/property-common'); -describe('ValueProperty', function () { +describe('ValueProperty', function() { var OurTestTemplate; /** * Get all the objects we need in this test here. */ - before(function () { + before(function() { OurTestTemplate = { typeid: 'autodesk.tests:TestID-1.0.0', properties: [{ - id: 'MyFloat', typeid: 'Float32' + id: 'MyFloat', typeid: 'Float32', }, { - id: 'MyInt', typeid: 'Int32' + id: 'MyInt', typeid: 'Int32', }, { - id: 'MyBool', typeid: 'Bool' - } - ] + id: 'MyBool', typeid: 'Bool', + }, + ], }; PropertyFactory._reregister(OurTestTemplate); }); - describe('Allocating ValueProperty object with all parameters', function () { - it('should succeed', function (done) { + describe('Allocating ValueProperty object with all parameters', function() { + it('should succeed', function(done) { var vp; var error; try { @@ -49,13 +49,13 @@ describe('ValueProperty', function () { }); }); - describe('API methods', function () { - it('.getValue should work', function () { + describe('API methods', function() { + it('.getValue should work', function() { var myProp = PropertyFactory.create('Bool'); myProp.setValue(true); expect(myProp.getValue()).to.equal(true); }); - it('.setValue should work to set the value and return nothing', function () { + it('.setValue should work to set the value and return nothing', function() { var myProp = PropertyFactory.create('Int32'); expect(myProp.getValue()).to.equal(0); expect(myProp.setValue(88)).to.be.undefined; @@ -63,8 +63,8 @@ describe('ValueProperty', function () { }); }); - describe('Setting a ValueProperty to the same value should not dirty it', function () { - it('should not be dirty', function (done) { + describe('Setting a ValueProperty to the same value should not dirty it', function() { + it('should not be dirty', function(done) { var error; var vp; try { @@ -90,7 +90,7 @@ describe('ValueProperty', function () { }); }); - it('value properties should support default values', function () { + it('value properties should support default values', function() { expect(PropertyFactory.create('Int8', undefined, 10).value).to.equal(10); expect(PropertyFactory.create('Uint8', undefined, 10).value).to.equal(10); expect(PropertyFactory.create('Int16', undefined, 10).value).to.equal(10); @@ -109,8 +109,8 @@ describe('ValueProperty', function () { expect(PropertyFactory.create('Reference', undefined, '/').value).to.equal('/'); }); - describe('ValueProperty serialize/deserialize tests', function () { - it('should correctly serialize/deserialize', function () { + describe('ValueProperty serialize/deserialize tests', function() { + it('should correctly serialize/deserialize', function() { var int32Prop = PropertyFactory.create('Int32'); int32Prop.value = 11; @@ -128,5 +128,4 @@ describe('ValueProperty', function () { expect(anotherInt32Prop.value).to.be.equal(11); }); }); - }); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/propertyFactory.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/propertyFactory.spec.js index 5957fa3ab350..d0d206d73315 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/propertyFactory.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/propertyFactory.spec.js @@ -5,12 +5,12 @@ /* globals sinon */ /* eslint-disable no-unused-expressions */ -const { PropertyFactory } = require('..'); const { MSG } = require('@fluid-experimental/property-common').constants; const { generateGUID } = require('@fluid-experimental/property-common').GuidUtils; +const { PropertyFactory } = require('..'); const { StringProperty } = require('../properties/stringProperty'); -describe('PropertyFactory', function () { +describe('PropertyFactory', function() { beforeEach(() => { PropertyFactory._clear(); }); @@ -23,40 +23,40 @@ describe('PropertyFactory', function () { properties: [ { id: 'x', - typeid: 'Float32' + typeid: 'Float32', }, { id: 'y', - typeid: 'Float32' + typeid: 'Float32', }, { id: 'z', - typeid: 'Float32' - } - ] + typeid: 'Float32', + }, + ], }, { id: 'normal', typeid: 'Float32', context: 'array', - size: 3 - } - ] + size: 3, + }, + ], }; - it('is not a function.', function (done) { + it('is not a function.', function(done) { expect(PropertyFactory).to.not.be.a('function'); expect(PropertyFactory).to.be.an('object'); done(); }); - it('should validate a simple file', function () { + it('should validate a simple file', function() { var testFile1 = require('./validation/goodPointId'); var result = PropertyFactory.validate(testFile1); expect(result.isValid).to.equal(true); }); - it('should fail an invalid file', function () { + it('should fail an invalid file', function() { var testFile1 = require('./validation/badPrimitiveTypeid'); var result = PropertyFactory.validate(testFile1); expect(result.isValid).to.equal(false); @@ -64,7 +64,7 @@ describe('PropertyFactory', function () { expect(result.unresolvedTypes.length).to.equal(1); }); - it('should create and initialize a property set', function () { + it('should create and initialize a property set', function() { PropertyFactory.register(SimplePoint); var goodPointTest = PropertyFactory.create('SimpleTest:PointID-1.0.0'); expect(goodPointTest.resolvePath('normal')._dataArrayRef._buffer.length).to.equal(3); @@ -73,51 +73,51 @@ describe('PropertyFactory', function () { position: { x: 0.0, y: 1.0, - z: 2.0 + z: 2.0, }, - normal: [1.23, 2.3399999141693115, 3.45] + normal: [1.23, 2.3399999141693115, 3.45], }); expect(goodPoint.resolvePath('normal').get(1)).to.equal(2.3399999141693115); }); - it('should throw on unknown Template', function () { + it('should throw on unknown Template', function() { var insertUnknownPropertyChangeSet = { insert: { 'UnknownProperty': { 'test': { String: { - 'unknownStringProperty': 'Hi There!' - } - } - } - } + 'unknownStringProperty': 'Hi There!', + }, + }, + }, + }, }; var root = PropertyFactory.create('NodeProperty'); expect( - function () { + function() { root.deserialize(insertUnknownPropertyChangeSet); }).to.throw(); }); - it('should throw when trying to create with undefined as typeid', function () { - var creationFunction = function () { + it('should throw when trying to create with undefined as typeid', function() { + var creationFunction = function() { PropertyFactory.create(undefined); }; expect(creationFunction).to.throw(MSG.UNKNOWN_TYPEID_SPECIFIED + 'undefined'); }); - it('should throw when trying to create with a number as typeid', function () { - var creationFunction = function () { + it('should throw when trying to create with a number as typeid', function() { + var creationFunction = function() { PropertyFactory.create(1); }; expect(creationFunction).to.throw(MSG.UNKNOWN_TYPEID_SPECIFIED + '1'); }); - it('should support the creation of a polymorphic collection', function () { + it('should support the creation of a polymorphic collection', function() { var testSet = { typeid: 'autodesk.examples:test.set-1.0.0', - inherits: 'NamedProperty' + inherits: 'NamedProperty', }; PropertyFactory.register(testSet); @@ -125,9 +125,9 @@ describe('PropertyFactory', function () { typeid: 'autodesk.examples:polymorphic.collection.test-1.0.0', properties: [ { id: 'testMap', context: 'map' }, - { id: 'testSet', typeid: 'autodesk.examples:test.set-1.0.0', context: 'set' } + { id: 'testSet', typeid: 'autodesk.examples:test.set-1.0.0', context: 'set' }, // TODO: add array as soon as polymorphic arrays are supported: {id: 'testArray', context:'array' } - ] + ], }; PropertyFactory._reregister(testTemplate); @@ -142,7 +142,7 @@ describe('PropertyFactory', function () { expect(PropertyFactory.inheritsFrom(instance._properties.testSet.getTypeid(), 'NamedProperty')).to.equal(true); }); - it('should return correct template based on typeid', function () { + it('should return correct template based on typeid', function() { PropertyFactory.register(SimplePoint); var returnedTemplate = JSON.parse(JSON.stringify(PropertyFactory.getTemplate(SimplePoint.typeid))); if (!SimplePoint.annotation) { @@ -157,8 +157,8 @@ describe('PropertyFactory', function () { expect(PropertyFactory.getTemplate('Adsk.Library:Colors.ColorPalette-1.0.0')).to.be.undefined; }); - describe('Inheritance', function () { - beforeEach(function () { + describe('Inheritance', function() { + beforeEach(function() { PropertyFactory._clear(); var Shape = { @@ -173,10 +173,10 @@ describe('PropertyFactory', function () { { id: 'height', typeid: 'Float32' }, { id: 'border', properties: [ - { id: 'weight', typeid: 'Int32' }] - }] - }] - }] + { id: 'weight', typeid: 'Int32' }], + }], + }], + }], }; PropertyFactory.register(Shape); @@ -186,8 +186,8 @@ describe('PropertyFactory', function () { { id: 'stroke', typeid: 'String' }, { id: 'fill', properties: [ - { id: 'rgb', typeid: 'String' }] - }] + { id: 'rgb', typeid: 'String' }], + }], }; PropertyFactory.register(Color); @@ -195,8 +195,8 @@ describe('PropertyFactory', function () { typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', inherits: ['NamedProperty'], properties: [ - { id: 'string', typeid: 'String', value: 'entry_string' } - ] + { id: 'string', typeid: 'String', value: 'entry_string' }, + ], }; PropertyFactory.register(EntryWithOverriddenDefaults); @@ -204,8 +204,8 @@ describe('PropertyFactory', function () { typeid: 'SimpleTest:EntryWithOverriddenPolyDefaults-1.0.0', inherits: ['SimpleTest:EntryWithOverriddenDefaults-1.0.0'], properties: [ - { id: 'string', typeid: 'String', value: 'entry_string' } - ] + { id: 'string', typeid: 'String', value: 'entry_string' }, + ], }; PropertyFactory.register(EntryWithOverriddenPolyDefaults); @@ -215,21 +215,21 @@ describe('PropertyFactory', function () { { id: 'num', typeid: 'Uint32' }, { id: 'dynamic', properties: [ - { id: 'dynamic_string', typeid: 'String' } - ] - } - ] + { id: 'dynamic_string', typeid: 'String' }, + ], + }, + ], }; PropertyFactory.register(DynamicWithOverriddenDefaults); }); - it('should allow the creation of an inherited type', function () { + it('should allow the creation of an inherited type', function() { var Square = { typeid: 'SimpleTest:Square-1.0.0', inherits: ['SimpleTest:Shape-1.0.0'], properties: [ - { id: 'area', typeid: 'Float32' } - ] + { id: 'area', typeid: 'Float32' }, + ], }; PropertyFactory.register(Square); @@ -241,21 +241,21 @@ describe('PropertyFactory', function () { expect(square.get('area')).to.exist; }); - it('should inherit constants', function () { + it('should inherit constants', function() { var ShapeWithConstant = { typeid: 'SimpleTest:ShapeWithConstant-1.0.0', inherits: ['SimpleTest:Shape-1.0.0'], constants: [ - { id: 'originX', typeid: 'Int8', value: 10 } - ] + { id: 'originX', typeid: 'Int8', value: 10 }, + ], }; var SquareWithConstant = { typeid: 'SimpleTest:SquareWithConstant-1.0.0', inherits: ['SimpleTest:ShapeWithConstant-1.0.0'], constants: [ - { id: 'originY', typeid: 'Int8', value: 20 } - ] + { id: 'originY', typeid: 'Int8', value: 20 }, + ], }; PropertyFactory.register(ShapeWithConstant); @@ -273,7 +273,7 @@ describe('PropertyFactory', function () { expect(square.get('originY').getValue()).to.equal(20); }); - it('Will complete constants definition from inherited template', function () { + it('Will complete constants definition from inherited template', function() { var template1 = { typeid: 'consttest:template-1.0.0', constants: [ @@ -281,16 +281,16 @@ describe('PropertyFactory', function () { id: 'const1', typeid: 'String', value: 'hello', - annotation: { description: 'The first constant.' } + annotation: { description: 'The first constant.' }, }, { id: 'const2', typeid: 'String', value: ['hello'], context: 'array', - annotation: { description: 'The second constant.' } - } - ] + annotation: { description: 'The second constant.' }, + }, + ], }; var testedTemplate = { @@ -299,13 +299,13 @@ describe('PropertyFactory', function () { constants: [ { id: 'const1', - value: 'hello2' + value: 'hello2', }, { id: 'const2', - value: ['hello2'] - } - ] + value: ['hello2'], + }, + ], }; PropertyFactory.register(testedTemplate); @@ -319,7 +319,7 @@ describe('PropertyFactory', function () { expect(tested.get('const2').getValues()).to.deep.equal(['hello2']); }); - it('Will throw because typeid is still missing at creation', function () { + it('Will throw because typeid is still missing at creation', function() { var template1 = { typeid: 'consttest2:template-1.0.0', constants: [ @@ -327,9 +327,9 @@ describe('PropertyFactory', function () { id: 'const2', typeid: 'String', value: 'hello', - annotation: { description: 'The first constant.' } - } - ] + annotation: { description: 'The first constant.' }, + }, + ], }; var testedTemplate = { @@ -338,9 +338,9 @@ describe('PropertyFactory', function () { constants: [ { id: 'const1', - value: 'hello2' - } - ] + value: 'hello2', + }, + ], }; PropertyFactory.register(template1); @@ -351,12 +351,12 @@ describe('PropertyFactory', function () { } catch (error) { expect(error.message).to.include( 'PF-043: Field "typeid" is required.' + - ' It is the "typeid" of the resulting PropertySets Template.const1.typeid' + ' It is the "typeid" of the resulting PropertySets Template.const1.typeid', ); } }); - it('Will throw because of a type mismatch when creating template', function () { + it('Will throw because of a type mismatch when creating template', function() { var template1 = { typeid: 'consttest3:template-1.0.0', constants: [ @@ -364,9 +364,9 @@ describe('PropertyFactory', function () { id: 'const1', typeid: 'String', value: 'hello', - annotation: { description: 'The first constant.' } - } - ] + annotation: { description: 'The first constant.' }, + }, + ], }; var template2 = { @@ -375,9 +375,9 @@ describe('PropertyFactory', function () { { id: 'const1', typeid: 'Uint8', - value: 3 - } - ] + value: 3, + }, + ], }; var testedTemplate = { @@ -386,9 +386,9 @@ describe('PropertyFactory', function () { constants: [ { id: 'const1', - value: 'hello2' - } - ] + value: 'hello2', + }, + ], }; PropertyFactory.register(template2); @@ -399,26 +399,26 @@ describe('PropertyFactory', function () { PropertyFactory.create('consttest3:template-3.0.0'); } catch (error) { expect(error.message).to.include( - 'PF-001: Id already exists: const1' + 'PF-001: Id already exists: const1', ); } }); - it('Will fail if inheriting constants with the same id from multiple templates', function () { + it('Will fail if inheriting constants with the same id from multiple templates', function() { var template1 = { typeid: 'consttest4:template-1.0.0', constants: [ { id: 'const1', typeid: 'String', - value: 'hello' + value: 'hello', }, { id: 'const2', typeid: 'Uint8', - value: 5 - } - ] + value: 5, + }, + ], }; var template2 = { @@ -428,9 +428,9 @@ describe('PropertyFactory', function () { id: 'const1', typeid: 'String', value: 'bye', - annotation: { description: 'The first constant.' } - } - ] + annotation: { description: 'The first constant.' }, + }, + ], }; var testedTemplate = { @@ -439,13 +439,13 @@ describe('PropertyFactory', function () { constants: [ { id: 'const1', - value: 'hello2' + value: 'hello2', }, { id: 'const2', - value: 14 - } - ] + value: 14, + }, + ], }; PropertyFactory.register(testedTemplate); @@ -456,7 +456,7 @@ describe('PropertyFactory', function () { .to.throw(MSG.OVERWRITING_ID + 'const1'); }); - it('Will allow to register the same inherited template again', function () { + it('Will allow to register the same inherited template again', function() { var template1 = { typeid: 'consttest5:template-1.0.0', constants: [ @@ -464,9 +464,9 @@ describe('PropertyFactory', function () { id: 'const1', typeid: 'String', value: 'hello', - annotation: { description: 'The first constant.' } - } - ] + annotation: { description: 'The first constant.' }, + }, + ], }; var testedTemplate = { @@ -475,9 +475,9 @@ describe('PropertyFactory', function () { constants: [ { id: 'const1', - value: 'hello2' - } - ] + value: 'hello2', + }, + ], }; PropertyFactory.register(template1); @@ -485,7 +485,7 @@ describe('PropertyFactory', function () { PropertyFactory.register(testedTemplate); }); - it('Will not allow to register a different template under the same id', function () { + it('Will not allow to register a different template under the same id', function() { var template1 = { typeid: 'consttest6:template-1.0.0', constants: [ @@ -493,9 +493,9 @@ describe('PropertyFactory', function () { id: 'const1', typeid: 'String', value: 'hello', - annotation: { description: 'The first constant.' } - } - ] + annotation: { description: 'The first constant.' }, + }, + ], }; var testedTemplate = { @@ -504,9 +504,9 @@ describe('PropertyFactory', function () { constants: [ { id: 'const1', - value: 'hello2' - } - ] + value: 'hello2', + }, + ], }; var testedTemplate2 = { @@ -515,9 +515,9 @@ describe('PropertyFactory', function () { constants: [ { id: 'const1', - value: 'hello3' - } - ] + value: 'hello3', + }, + ], }; try { @@ -527,12 +527,12 @@ describe('PropertyFactory', function () { throw new Error('Should have failed'); } catch (error) { expect(error.message).to.include( - 'PF-004: Template structures do not match for typeid: consttest6:template-2.0.0' + 'PF-004: Template structures do not match for typeid: consttest6:template-2.0.0', ); } }); - it('Wont register if constant id is missing', function () { + it('Wont register if constant id is missing', function() { var template1 = { typeid: 'consttest7:template-1.0.0', constants: [ @@ -540,9 +540,9 @@ describe('PropertyFactory', function () { id: 'const1', typeid: 'String', value: 'hello', - annotation: { description: 'The first constant.' } - } - ] + annotation: { description: 'The first constant.' }, + }, + ], }; var testedTemplate = { @@ -550,9 +550,9 @@ describe('PropertyFactory', function () { inherits: 'consttest7:template-1.0.0', constants: [ { - value: 'hello2' - } - ] + value: 'hello2', + }, + ], }; try { @@ -561,22 +561,22 @@ describe('PropertyFactory', function () { throw new Error('Should have failed'); } catch (error) { expect(error.message).to.include( - 'PF-050: Failed to register typeid = consttest7:template-2.0.0' + 'PF-050: Failed to register typeid = consttest7:template-2.0.0', ); } }); - it('should allow inheriting from schemas with no properties defined', function () { + it('should allow inheriting from schemas with no properties defined', function() { var ShapeAbstract1 = { - typeid: 'SimpleTest:ShapeAbstract1-1.0.0' + typeid: 'SimpleTest:ShapeAbstract1-1.0.0', }; var ShapeAbstract2 = { typeid: 'SimpleTest:ShapeAbstract2-1.0.0', properties: [ { id: 'area', properties: [] }, - { id: 'color' } - ] + { id: 'color' }, + ], }; var SquareAbstract = { @@ -587,10 +587,10 @@ describe('PropertyFactory', function () { { id: 'originY' }, { id: 'color', properties: [ - { id: 'rgb', typeid: 'Int64' } - ] - } - ] + { id: 'rgb', typeid: 'Int64' }, + ], + }, + ], }; PropertyFactory.register(ShapeAbstract1); @@ -607,13 +607,13 @@ describe('PropertyFactory', function () { expect(square.get(['color', 'rgb'])).to.exist; }); - it('should allow multiple inheritance', function () { + it('should allow multiple inheritance', function() { var SquareWithColor = { typeid: 'SimpleTest:SquareWithColor-1.0.0', inherits: ['SimpleTest:Shape-1.0.0', 'SimpleTest:Color-1.0.0'], properties: [ - { id: 'area', typeid: 'Float32' } - ] + { id: 'area', typeid: 'Float32' }, + ], }; PropertyFactory.register(SquareWithColor); @@ -627,22 +627,22 @@ describe('PropertyFactory', function () { expect(square.get('fill')).to.exist; }); - it('should fail when inheriting from multiple types that have the same property name', function () { + it('should fail when inheriting from multiple types that have the same property name', function() { var Point = { typeid: 'SimpleTest:Point-1.0.0', properties: [{ id: 'props', properties: [ { id: 'x', typeid: 'Float32' }, - { id: 'y', typeid: 'Float32' }] - }] + { id: 'y', typeid: 'Float32' }], + }], }; var ShapeWithInheritanceError = { typeid: 'SimpleTest:ShapeWithInheritanceError-1.0.0', inherits: ['SimpleTest:Shape-1.0.0', 'SimpleTest:Point-1.0.0'], properties: [ - { id: 'weight', typeid: 'Float32' } - ] + { id: 'weight', typeid: 'Float32' }, + ], }; PropertyFactory.register(Point); @@ -652,11 +652,11 @@ describe('PropertyFactory', function () { .to.throw(MSG.OVERWRITING_ID + 'props'); }); - it('should fail when overriding an inherited typed property', function () { + it('should fail when overriding an inherited typed property', function() { var ShapeWithOverridesError = { typeid: 'SimpleTest:ShapeWithOverridesError-1.0.0', inherits: ['SimpleTest:Shape-1.0.0'], - properties: [{ id: 'props', typeid: 'Float32' }] + properties: [{ id: 'props', typeid: 'Float32' }], }; PropertyFactory.register(ShapeWithOverridesError); @@ -665,7 +665,7 @@ describe('PropertyFactory', function () { .to.throw(MSG.OVERRIDEN_PROP_MUST_HAVE_SAME_FIELD_VALUES_AS_BASE_TYPE); }); - it('should allow extending inherited nested untyped properties', function () { + it('should allow extending inherited nested untyped properties', function() { var SquareWithOverrides = { typeid: 'SimpleTest:SquareWithOverrides-1.0.0', inherits: ['SimpleTest:Shape-1.0.0', 'SimpleTest:Color-1.0.0'], @@ -679,14 +679,14 @@ describe('PropertyFactory', function () { { id: 'unit', typeid: 'Int32' }, { id: 'border', properties: [ - { id: 'color', typeid: 'String' }] - }] - }] + { id: 'color', typeid: 'String' }], + }], + }], }, { id: 'fill', properties: [ - { id: 'unit', typeid: 'Int32' }] - }] + { id: 'unit', typeid: 'Int32' }], + }], }; PropertyFactory.register(SquareWithOverrides); @@ -720,7 +720,7 @@ describe('PropertyFactory', function () { expect(square.get(['fill', 'unit'])).to.exist; }); - it('should support more than one level of inheritance', function () { + it('should support more than one level of inheritance', function() { var ShapeWithArea = { typeid: 'SimpleTest:ShapeWithArea-1.0.0', inherits: ['SimpleTest:Shape-1.0.0'], @@ -729,9 +729,9 @@ describe('PropertyFactory', function () { id: 'props', properties: [ { id: 'area', properties: [ - { id: 'length', typeid: 'Float32' }] - }] - }] + { id: 'length', typeid: 'Float32' }], + }], + }], }; var SquareWithArea = { @@ -744,9 +744,9 @@ describe('PropertyFactory', function () { { id: 'color', typeid: 'String' }, { id: 'area', properties: [ - { id: 'unit', typeid: 'String' }] - }] - }] + { id: 'unit', typeid: 'String' }], + }], + }], }; PropertyFactory.register(ShapeWithArea); @@ -770,7 +770,7 @@ describe('PropertyFactory', function () { expect(square.get(['props', 'area', 'length'])).to.exist; }); - it('should work with properties named "length"', function () { + it('should work with properties named "length"', function() { var DefaultInitialValue = { 'typeid': 'autodesk.product:components.physicalProperties-0.0.0', 'properties': [ @@ -779,43 +779,43 @@ describe('PropertyFactory', function () { 'properties': [ { 'id': 'value', - 'typeid': 'Float64' + 'typeid': 'Float64', }, { 'id': 'unit', - 'typeid': 'String' - } - ] + 'typeid': 'String', + }, + ], }, { 'id': 'boundingBox', 'properties': [ { 'id': 'length', - 'typeid': 'Float64' + 'typeid': 'Float64', }, { 'id': 'width', - 'typeid': 'Float64' + 'typeid': 'Float64', }, { 'id': 'height', - 'typeid': 'Float64' + 'typeid': 'Float64', }, { 'id': 'unit', - 'typeid': 'String' - } - ] + 'typeid': 'String', + }, + ], }, { 'id': 'material', - 'typeid': 'String' - } + 'typeid': 'String', + }, ], 'annotation': { - 'description': 'Specialized component storing physical properties computed from a model.' - } + 'description': 'Specialized component storing physical properties computed from a model.', + }, }; PropertyFactory.register(DefaultInitialValue); @@ -823,36 +823,36 @@ describe('PropertyFactory', function () { var prop = PropertyFactory.create('autodesk.product:components.physicalProperties-0.0.0', null, { mass: { value: 1.2, - unit: 'units' + unit: 'units', }, boundingBox: { length: 1.2, width: 1.4, height: 34.2, - unit: 'units' + unit: 'units', }, - material: 'ABS Plastic' + material: 'ABS Plastic', }); expect(prop.get('boundingBox').get('length').value).to.equal(1.2); }); - describe('Overriding default values', function () { - it('should allow overriding default values', function () { + describe('Overriding default values', function() { + it('should allow overriding default values', function() { var MapNestedWithOverriddenDefaults = { typeid: 'SimpleTest:MapNestedWithOverriddenDefaults-1.0.0', inherits: ['NamedProperty'], properties: [{ - id: 'map_nested', typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', context: 'map' - }] + id: 'map_nested', typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', context: 'map', + }], }; var SetNestedWithOverriddenDefaults = { typeid: 'SimpleTest:SetNestedWithOverriddenDefaults-1.0.0', inherits: ['NamedProperty'], properties: [{ - id: 'set_nested', typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', context: 'set' - }] + id: 'set_nested', typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', context: 'set', + }], }; var ShapeWithOverriddenDefaults = { @@ -862,82 +862,82 @@ describe('PropertyFactory', function () { { id: 'array', typeid: 'String', value: ['array_string_1', 'array_string_2'], context: 'array' }, { id: 'array_poly', typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', context: 'array', value: [ - { string: 'entry_string_poly' }] + { string: 'entry_string_poly' }], }, { id: 'enum', typeid: 'Enum', properties: [{ id: 'solid', value: 1 }, { id: 'dashed', value: 2 }], - value: 'solid' + value: 'solid', }, { id: 'untyped', properties: [ { id: 'num', typeid: 'Uint32' }, - { id: 'string', typeid: 'String' } - ], value: { string: 'untyped_string', num: 1 } + { id: 'string', typeid: 'String' }, + ], value: { string: 'untyped_string', num: 1 }, }, { id: 'template', typeid: 'SimpleTest:DynamicWithOverriddenDefaults-1.0.0', value: { - num: 1, dynamic: { dynamic_string: 'dynamic_string' } - } + num: 1, dynamic: { dynamic_string: 'dynamic_string' }, + }, }, { id: 'map_primitive', typeid: 'Int32', context: 'map', value: { key1: 1, - key3: 3 - } + key3: 3, + }, }, { id: 'map', typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', context: 'map', value: { key1: { string: 'map_string_1' }, - key3: { string: 'map_string_3' } - } + key3: { string: 'map_string_3' }, + }, }, { id: 'map_poly', typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', context: 'map', value: { key1: { string: 'map_poly_string_1' }, - key3: { string: 'map_poly_string_3' } - } + key3: { string: 'map_poly_string_3' }, + }, }, { id: 'map_nest', typeid: 'SimpleTest:MapNestedWithOverriddenDefaults-1.0.0', context: 'map', value: { key1: { map_nested: { key1_1: { string: 'map_nested_1_string_1' }, - key1_3: { string: 'map_nested_1_string_3' } - } + key1_3: { string: 'map_nested_1_string_3' }, + }, }, key3: { map_nested: { - key3_1: { string: 'map_nested_3_string_1' } - } - } - } + key3_1: { string: 'map_nested_3_string_1' }, + }, + }, + }, }, { id: 'set', typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', context: 'set', value: [ { string: 'set_string_1' }, - { string: 'set_string_2' } - ] + { string: 'set_string_2' }, + ], }, { id: 'set_poly', typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', context: 'set', value: [ { string: 'set_poly_string_1' }, - { string: 'set_poly_string_1' } - ] + { string: 'set_poly_string_1' }, + ], }, { id: 'set_nest', typeid: 'SimpleTest:SetNestedWithOverriddenDefaults-1.0.0', context: 'set', value: [{ set_nested: [ { string: 'set_nested_1_string_1' }, - { string: 'set_nested_1_string_2' } - ] + { string: 'set_nested_1_string_2' }, + ], }, { set_nested: [ { string: 'set_nested_3_string_1' }, - { string: 'set_nested_3_string_2' } - ] - }] - } - ] + { string: 'set_nested_3_string_2' }, + ], + }], + }, + ], }; var SquareWithOverriddenDefaults = { @@ -947,101 +947,101 @@ describe('PropertyFactory', function () { { id: 'num', typeid: 'Int8', value: 2 }, { id: 'array', typeid: 'String', value: ['array_string_1_inherited', 'array_string_2_inherited'], - context: 'array' + context: 'array', }, { id: 'array_poly', typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', context: 'array', typedValue: [{ typeid: 'SimpleTest:EntryWithOverriddenPolyDefaults-1.0.0', - value: { string: 'entry_string_poly_1_inherited' } + value: { string: 'entry_string_poly_1_inherited' }, }, { typeid: 'SimpleTest:EntryWithOverriddenPolyDefaults-1.0.0', - value: { string: 'entry_string_poly_2_inherited' } - } - ] + value: { string: 'entry_string_poly_2_inherited' }, + }, + ], }, { id: 'enum', typeid: 'Enum', properties: [{ id: 'solid', value: 1 }, { id: 'dashed', value: 2 }], - value: 'dashed' + value: 'dashed', }, { id: 'untyped', properties: [ { id: 'num', typeid: 'Uint32' }, - { id: 'string', typeid: 'String' } - ], value: { string: 'untyped_string_inherited', num: 2 } + { id: 'string', typeid: 'String' }, + ], value: { string: 'untyped_string_inherited', num: 2 }, }, { id: 'template', typeid: 'SimpleTest:DynamicWithOverriddenDefaults-1.0.0', value: { - num: 2, dynamic: { dynamic_string: 'dynamic_string_inherited' } - } + num: 2, dynamic: { dynamic_string: 'dynamic_string_inherited' }, + }, }, { id: 'map_primitive', typeid: 'Int32', context: 'map', value: { key2: 2, - key3: 3 - } + key3: 3, + }, }, { id: 'map', typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', context: 'map', value: { key2: { string: 'map_string_2_inherited' }, - key3: { string: 'map_string_3_inherited' } - } + key3: { string: 'map_string_3_inherited' }, + }, }, { id: 'map_poly', typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', context: 'map', typedValue: { key2: { typeid: 'SimpleTest:EntryWithOverriddenPolyDefaults-1.0.0', - value: { string: 'map_poly_string_2_inherited' } + value: { string: 'map_poly_string_2_inherited' }, }, key3: { typeid: 'SimpleTest:EntryWithOverriddenPolyDefaults-1.0.0', - value: { string: 'map_poly_string_3_inherited' } - } - } + value: { string: 'map_poly_string_3_inherited' }, + }, + }, }, { id: 'map_nest', typeid: 'SimpleTest:MapNestedWithOverriddenDefaults-1.0.0', context: 'map', value: { key2: { map_nested: { key2_2: { string: 'map_nested_2_string_2_inherited' }, - key2_3: { string: 'map_nested_2_string_3_inherited' } - } + key2_3: { string: 'map_nested_2_string_3_inherited' }, + }, }, key3: { map_nested: { - key3_1: { string: 'map_nested_3_string_1_inherited' } - } - } - } + key3_1: { string: 'map_nested_3_string_1_inherited' }, + }, + }, + }, }, { id: 'set', typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', context: 'set', value: [ { string: 'set_string_2_inherited' }, - { string: 'set_string_3_inherited' } - ] + { string: 'set_string_3_inherited' }, + ], }, { id: 'set_poly', typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', context: 'set', typedValue: [ { typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', - value: { string: 'set_poly_string_2_inherited' } + value: { string: 'set_poly_string_2_inherited' }, }, { typeid: 'SimpleTest:EntryWithOverriddenDefaults-1.0.0', - value: { string: 'set_poly_string_3_inherited' } - } - ] + value: { string: 'set_poly_string_3_inherited' }, + }, + ], }, { id: 'set_nest', typeid: 'SimpleTest:SetNestedWithOverriddenDefaults-1.0.0', context: 'set', value: [{ set_nested: [ { string: 'set_nested_2_string_1_inherited' }, - { string: 'set_nested_2_string_2_inherited' } - ] - }] - } - ] + { string: 'set_nested_2_string_2_inherited' }, + ], + }], + }, + ], }; PropertyFactory.register(MapNestedWithOverriddenDefaults); @@ -1054,7 +1054,7 @@ describe('PropertyFactory', function () { expect(instance._getChildrenCount()).to.equal(13); expect(instance.resolvePath('num').getValue()).and.eql(2); expect(instance.resolvePath('array').getValues()).and.eql([ - 'array_string_1_inherited', 'array_string_2_inherited' + 'array_string_1_inherited', 'array_string_2_inherited', ]); expect(instance.resolvePath('array_poly').getValues().length).to.eql(2); expect(instance.resolvePath('array_poly').getValues()[0].string).to.eql('entry_string_poly_1_inherited'); @@ -1109,16 +1109,16 @@ describe('PropertyFactory', function () { .getAsArray()[1].get('string').getValue()).to.equal('set_nested_2_string_2_inherited'); }); - it('should not allow overriding default values when typeid is different', function () { + it('should not allow overriding default values when typeid is different', function() { var ShapeWithDiffTypeidDefaults = { typeid: 'SimpleTest:ShapeWithDiffTypeidDefaults-1.0.0', - properties: [{ id: 'num', typeid: 'Int8', value: 1 }] + properties: [{ id: 'num', typeid: 'Int8', value: 1 }], }; var SquareWithDiffTypeidDefaults = { typeid: 'SimpleTest:SquareWithDiffTypeidDefaults-1.0.0', inherits: ['SimpleTest:ShapeWithDiffTypeidDefaults-1.0.0'], - properties: [{ id: 'num', typeid: 'Int32', value: 2 }] + properties: [{ id: 'num', typeid: 'Int32', value: 2 }], }; PropertyFactory.register(ShapeWithDiffTypeidDefaults); @@ -1128,16 +1128,16 @@ describe('PropertyFactory', function () { .to.throw(MSG.OVERRIDEN_PROP_MUST_HAVE_SAME_FIELD_VALUES_AS_BASE_TYPE); }); - it('should not allow overriding default values when context is different', function () { + it('should not allow overriding default values when context is different', function() { var ShapeWithDiffContextDefaults = { typeid: 'SimpleTest:ShapeWithDiffContextDefaults-1.0.0', - properties: [{ id: 'num', typeid: 'Int8', value: 1 }] + properties: [{ id: 'num', typeid: 'Int8', value: 1 }], }; var SquareWithDiffContextDefaults = { typeid: 'SimpleTest:SquareWithDiffContextDefaults-1.0.0', inherits: ['SimpleTest:ShapeWithDiffContextDefaults-1.0.0'], - properties: [{ id: 'num', typeid: 'Int8', value: [1, 2], context: 'array' }] + properties: [{ id: 'num', typeid: 'Int8', value: [1, 2], context: 'array' }], }; PropertyFactory.register(ShapeWithDiffContextDefaults); @@ -1148,22 +1148,22 @@ describe('PropertyFactory', function () { }); }); - describe('Overriding constants', function () { - it('should allow overriding constants', function () { + describe('Overriding constants', function() { + it('should allow overriding constants', function() { var EntryWithOverriddenConstants = { typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', inherits: ['NamedProperty'], constants: [ - { id: 'string', typeid: 'String', value: 'entry_string' } - ] + { id: 'string', typeid: 'String', value: 'entry_string' }, + ], }; var EntryWithOverriddenPolyConstants = { typeid: 'SimpleTest:EntryWithOverriddenPolyConstants-1.0.0', inherits: ['SimpleTest:EntryWithOverriddenConstants-1.0.0'], constants: [ - { id: 'string', typeid: 'String', value: 'entry_string' } - ] + { id: 'string', typeid: 'String', value: 'entry_string' }, + ], }; var DynamicWithOverriddenConstants = { @@ -1172,26 +1172,26 @@ describe('PropertyFactory', function () { properties: [ { id: 'dynamic', properties: [ - { id: 'dynamic_string', typeid: 'String' } - ] - } - ] + { id: 'dynamic_string', typeid: 'String' }, + ], + }, + ], }; var MapNestedWithOverriddenConstants = { typeid: 'SimpleTest:MapNestedWithOverriddenConstants-1.0.0', inherits: ['NamedProperty'], constants: [{ - id: 'map_nested', typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', context: 'map', value: {} - }] + id: 'map_nested', typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', context: 'map', value: {}, + }], }; var SetNestedWithOverriddenConstants = { typeid: 'SimpleTest:SetNestedWithOverriddenConstants-1.0.0', inherits: ['NamedProperty'], constants: [{ - id: 'set_nested', typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', context: 'set', value: [] - }] + id: 'set_nested', typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', context: 'set', value: [], + }], }; var ShapeWithOverriddenConstants = { @@ -1201,72 +1201,72 @@ describe('PropertyFactory', function () { { id: 'array', typeid: 'String', value: ['array_string_1', 'array_string_2'], context: 'array' }, { id: 'array_poly', typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', context: 'array', value: [ - { string: 'entry_string_poly' }] + { string: 'entry_string_poly' }], }, { id: 'template', typeid: 'SimpleTest:DynamicWithOverriddenConstants-1.0.0', value: { - num: 1, dynamic: { dynamic_string: 'dynamic_string' } - } + num: 1, dynamic: { dynamic_string: 'dynamic_string' }, + }, }, { id: 'map_primitive', typeid: 'Int32', context: 'map', value: { key1: 1, - key3: 3 - } + key3: 3, + }, }, { id: 'map', typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', context: 'map', value: { key1: { string: 'map_string_1' }, - key3: { string: 'map_string_3' } - } + key3: { string: 'map_string_3' }, + }, }, { id: 'map_poly', typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', context: 'map', value: { key1: { string: 'map_poly_string_1' }, - key3: { string: 'map_poly_string_3' } - } + key3: { string: 'map_poly_string_3' }, + }, }, { id: 'map_nest', typeid: 'SimpleTest:MapNestedWithOverriddenConstants-1.0.0', context: 'map', value: { key1: { map_nested: { key1_1: { string: 'map_nested_1_string_1' }, - key1_3: { string: 'map_nested_1_string_3' } - } + key1_3: { string: 'map_nested_1_string_3' }, + }, }, key3: { map_nested: { - key3_1: { string: 'map_nested_3_string_1' } - } - } - } + key3_1: { string: 'map_nested_3_string_1' }, + }, + }, + }, }, { id: 'set', typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', context: 'set', value: [ { string: 'set_string_1' }, - { string: 'set_string_2' } - ] + { string: 'set_string_2' }, + ], }, { id: 'set_poly', typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', context: 'set', value: [ { string: 'set_poly_string_1' }, - { string: 'set_poly_string_1' } - ] + { string: 'set_poly_string_1' }, + ], }, { id: 'set_nest', typeid: 'SimpleTest:SetNestedWithOverriddenConstants-1.0.0', context: 'set', value: [{ set_nested: [ { string: 'set_nested_1_string_1' }, - { string: 'set_nested_1_string_2' } - ] + { string: 'set_nested_1_string_2' }, + ], }, { set_nested: [ { string: 'set_nested_3_string_1' }, - { string: 'set_nested_3_string_2' } - ] - }] - } - ] + { string: 'set_nested_3_string_2' }, + ], + }], + }, + ], }; var SquareWithOverriddenConstants = { @@ -1276,91 +1276,91 @@ describe('PropertyFactory', function () { { id: 'num', typeid: 'Int8', value: 2 }, { id: 'array', typeid: 'String', value: ['array_string_1_inherited', 'array_string_2_inherited'], - context: 'array' + context: 'array', }, { id: 'array_poly', typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', context: 'array', typedValue: [{ typeid: 'SimpleTest:EntryWithOverriddenPolyConstants-1.0.0', - value: { string: 'entry_string_poly_1_inherited' } + value: { string: 'entry_string_poly_1_inherited' }, }, { typeid: 'SimpleTest:EntryWithOverriddenPolyConstants-1.0.0', - value: { string: 'entry_string_poly_2_inherited' } - } - ] + value: { string: 'entry_string_poly_2_inherited' }, + }, + ], }, { id: 'template', typeid: 'SimpleTest:DynamicWithOverriddenConstants-1.0.0', value: { - num: 2, dynamic: { dynamic_string: 'dynamic_string_inherited' } - } + num: 2, dynamic: { dynamic_string: 'dynamic_string_inherited' }, + }, }, { id: 'map_primitive', typeid: 'Int32', context: 'map', value: { key2: 2, - key3: 3 - } + key3: 3, + }, }, { id: 'map', typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', context: 'map', value: { key2: { string: 'map_string_2_inherited' }, - key3: { string: 'map_string_3_inherited' } - } + key3: { string: 'map_string_3_inherited' }, + }, }, { id: 'map_poly', typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', context: 'map', typedValue: { key2: { typeid: 'SimpleTest:EntryWithOverriddenPolyConstants-1.0.0', - value: { string: 'map_poly_string_2_inherited' } + value: { string: 'map_poly_string_2_inherited' }, }, key3: { typeid: 'SimpleTest:EntryWithOverriddenPolyConstants-1.0.0', - value: { string: 'map_poly_string_3_inherited' } - } - } + value: { string: 'map_poly_string_3_inherited' }, + }, + }, }, { id: 'map_nest', typeid: 'SimpleTest:MapNestedWithOverriddenConstants-1.0.0', context: 'map', value: { key2: { map_nested: { key2_2: { string: 'map_nested_2_string_2_inherited' }, - key2_3: { string: 'map_nested_2_string_3_inherited' } - } + key2_3: { string: 'map_nested_2_string_3_inherited' }, + }, }, key3: { map_nested: { - key3_1: { string: 'map_nested_3_string_1_inherited' } - } - } - } + key3_1: { string: 'map_nested_3_string_1_inherited' }, + }, + }, + }, }, { id: 'set', typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', context: 'set', value: [ { string: 'set_string_2_inherited' }, - { string: 'set_string_3_inherited' } - ] + { string: 'set_string_3_inherited' }, + ], }, { id: 'set_poly', typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', context: 'set', typedValue: [ { typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', - value: { string: 'set_poly_string_2_inherited' } + value: { string: 'set_poly_string_2_inherited' }, }, { typeid: 'SimpleTest:EntryWithOverriddenConstants-1.0.0', - value: { string: 'set_poly_string_3_inherited' } - } - ] + value: { string: 'set_poly_string_3_inherited' }, + }, + ], }, { id: 'set_nest', typeid: 'SimpleTest:SetNestedWithOverriddenConstants-1.0.0', context: 'set', value: [{ set_nested: [ { string: 'set_nested_2_string_1_inherited' }, - { string: 'set_nested_2_string_2_inherited' } - ] - }] - } - ] + { string: 'set_nested_2_string_2_inherited' }, + ], + }], + }, + ], }; PropertyFactory.register(EntryWithOverriddenConstants); @@ -1376,7 +1376,7 @@ describe('PropertyFactory', function () { expect(instance._getChildrenCount()).to.equal(11); expect(instance.resolvePath('num').getValue()).and.eql(2); expect(instance.resolvePath('array').getValues()).and.eql([ - 'array_string_1_inherited', 'array_string_2_inherited' + 'array_string_1_inherited', 'array_string_2_inherited', ]); expect(instance.resolvePath('array_poly').getValues().length).to.eql(2); expect(instance.resolvePath('array_poly').getValues()[0].string).to.eql('entry_string_poly_1_inherited'); @@ -1428,13 +1428,13 @@ describe('PropertyFactory', function () { .getAsArray()[1].get('string').getValue()).to.equal('set_nested_2_string_2_inherited'); }); - it('should allow overriding constants with typed values', function () { + it('should allow overriding constants with typed values', function() { var EntryWithTypedOverriddenConstants = { typeid: 'SimpleTest:EntryWithTypedOverriddenConstants-1.0.0', inherits: ['NamedProperty'], constants: [ - { id: 'string', typeid: 'String', value: 'entry_string' } - ] + { id: 'string', typeid: 'String', value: 'entry_string' }, + ], }; var EntryWithTypedOverriddenPolyConstants = { @@ -1442,8 +1442,8 @@ describe('PropertyFactory', function () { inherits: ['SimpleTest:EntryWithTypedOverriddenConstants-1.0.0'], constants: [ { id: 'string', typeid: 'String', value: 'entry_string' }, - { id: 'name', typeid: 'String', value: 'entry2' } - ] + { id: 'name', typeid: 'String', value: 'entry2' }, + ], }; var ShapeWithTypedOverriddenConstants = { @@ -1453,21 +1453,21 @@ describe('PropertyFactory', function () { { id: 'entry2', typeid: 'SimpleTest:EntryWithTypedOverriddenConstants-1.0.0' }, { id: 'array', typeid: 'SimpleTest:EntryWithTypedOverriddenConstants-1.0.0', context: 'array', - value: [{ string: 'entry_string' }] + value: [{ string: 'entry_string' }], }, { id: 'map', typeid: 'SimpleTest:EntryWithTypedOverriddenConstants-1.0.0', context: 'map', value: { key1: { string: 'map_string_1' }, - key3: { string: 'map_string_3' } - } + key3: { string: 'map_string_3' }, + }, }, { id: 'set', typeid: 'SimpleTest:EntryWithTypedOverriddenConstants-1.0.0', context: 'set', value: [ { string: 'set_string_1' }, - { string: 'set_string_1' } - ] - } - ] + { string: 'set_string_1' }, + ], + }, + ], }; var SquareWithTypedOverriddenConstants = { @@ -1477,52 +1477,52 @@ describe('PropertyFactory', function () { { id: 'entry1', typedValue: { typeid: 'SimpleTest:EntryWithTypedOverriddenConstants-1.0.0', - value: { string: 'entry_string_1' } - } + value: { string: 'entry_string_1' }, + }, }, { id: 'entry2', typedValue: { typeid: 'SimpleTest:EntryWithTypedOverriddenPolyConstants-1.0.0', - value: { string: 'entry_string_2', name: 'entry2' } - } + value: { string: 'entry_string_2', name: 'entry2' }, + }, }, { id: 'array', context: 'array', typedValue: [{ typeid: 'SimpleTest:EntryWithTypedOverriddenPolyConstants-1.0.0', - value: { string: 'entry_string_1_inherited', name: 'entry_string_1' } + value: { string: 'entry_string_1_inherited', name: 'entry_string_1' }, }, { typeid: 'SimpleTest:EntryWithTypedOverriddenPolyConstants-1.0.0', - value: { string: 'entry_string_2_inherited', name: 'entry_string_2' } - } - ] + value: { string: 'entry_string_2_inherited', name: 'entry_string_2' }, + }, + ], }, { id: 'map', typeid: 'SimpleTest:EntryWithTypedOverriddenConstants-1.0.0', context: 'map', typedValue: { key2: { typeid: 'SimpleTest:EntryWithTypedOverriddenPolyConstants-1.0.0', - value: { string: 'map_string_2_inherited', name: 'map_string_2' } + value: { string: 'map_string_2_inherited', name: 'map_string_2' }, }, key3: { typeid: 'SimpleTest:EntryWithTypedOverriddenPolyConstants-1.0.0', - value: { string: 'map_string_3_inherited', name: 'map_string_3' } - } - } + value: { string: 'map_string_3_inherited', name: 'map_string_3' }, + }, + }, }, { id: 'set', typeid: 'SimpleTest:EntryWithTypedOverriddenConstants-1.0.0', context: 'set', typedValue: [ { typeid: 'SimpleTest:EntryWithTypedOverriddenPolyConstants-1.0.0', - value: { string: 'set_string_2_inherited', name: 'set_string_2' } + value: { string: 'set_string_2_inherited', name: 'set_string_2' }, }, { typeid: 'SimpleTest:EntryWithTypedOverriddenPolyConstants-1.0.0', - value: { string: 'set_string_3_inherited', name: 'set_string_3' } - } - ] - } - ] + value: { string: 'set_string_3_inherited', name: 'set_string_3' }, + }, + ], + }, + ], }; PropertyFactory.register(EntryWithTypedOverriddenConstants); @@ -1565,16 +1565,16 @@ describe('PropertyFactory', function () { .getValue()).to.equal('set_string_3_inherited'); }); - it('should not allow overriding constants when typeid is different', function () { + it('should not allow overriding constants when typeid is different', function() { var ShapeWithDiffTypeidConstants = { typeid: 'SimpleTest:ShapeWithDiffTypeidConstants-1.0.0', - constants: [{ id: 'num', typeid: 'Int8', value: 1 }] + constants: [{ id: 'num', typeid: 'Int8', value: 1 }], }; var SquareWithDiffTypeidConstants = { typeid: 'SimpleTest:SquareWithDiffTypeidConstants-1.0.0', inherits: ['SimpleTest:ShapeWithDiffTypeidConstants-1.0.0'], - constants: [{ id: 'num', typeid: 'Int32', value: 2 }] + constants: [{ id: 'num', typeid: 'Int32', value: 2 }], }; PropertyFactory.register(ShapeWithDiffTypeidConstants); @@ -1584,16 +1584,16 @@ describe('PropertyFactory', function () { .to.throw(MSG.OVERRIDEN_PROP_MUST_HAVE_SAME_FIELD_VALUES_AS_BASE_TYPE); }); - it('should not allow overriding constants when context is different', function () { + it('should not allow overriding constants when context is different', function() { var ShapeWithDiffContextConstants = { typeid: 'SimpleTest:ShapeWithDiffContextConstants-1.0.0', - constants: [{ id: 'num', typeid: 'Int8', value: 1 }] + constants: [{ id: 'num', typeid: 'Int8', value: 1 }], }; var SquareWithDiffContextConstants = { typeid: 'SimpleTest:SquareWithDiffContextConstants-1.0.0', inherits: ['SimpleTest:ShapeWithDiffContextConstants-1.0.0'], - constants: [{ id: 'num', typeid: 'Int8', value: [1, 2], context: 'array' }] + constants: [{ id: 'num', typeid: 'Int8', value: [1, 2], context: 'array' }], }; PropertyFactory.register(ShapeWithDiffContextConstants); @@ -1603,26 +1603,26 @@ describe('PropertyFactory', function () { .to.throw(MSG.OVERRIDEN_PROP_MUST_HAVE_SAME_FIELD_VALUES_AS_BASE_TYPE); }); - it('should not allow overriding constants with a typedValue that does not inherit from base type', function () { + it('should not allow overriding constants with a typedValue that does not inherit from base type', function() { var Type1 = { typeid: 'SimpleTest:Type1-1.0.0', - constants: [{ id: 'num', typeid: 'Int32', value: 1 }] + constants: [{ id: 'num', typeid: 'Int32', value: 1 }], }; var Type2 = { typeid: 'SimpleTest:Type2-1.0.0', - constants: [{ id: 'num', typeid: 'Int32', value: 1 }] + constants: [{ id: 'num', typeid: 'Int32', value: 1 }], }; var ShapeWithDiffTypedTypeidConstants = { typeid: 'SimpleTest:ShapeWithDiffTypeidConstants-1.0.0', - constants: [{ id: 'type', typeid: 'SimpleTest:Type1-1.0.0' }] + constants: [{ id: 'type', typeid: 'SimpleTest:Type1-1.0.0' }], }; var SquareWithDiffTypedTypeidConstants = { typeid: 'SimpleTest:SquareWithDiffTypeidConstants-1.0.0', inherits: ['SimpleTest:ShapeWithDiffTypeidConstants-1.0.0'], - constants: [{ id: 'type', typedValue: { typeid: 'SimpleTest:Type2-1.0.0' } }] + constants: [{ id: 'type', typedValue: { typeid: 'SimpleTest:Type2-1.0.0' } }], }; PropertyFactory.register(Type1); @@ -1637,15 +1637,14 @@ describe('PropertyFactory', function () { }); }); - - describe('Default values', function () { - it('should set default values for primitive property', function () { + describe('Default values', function() { + it('should set default values for primitive property', function() { var DefaultPrimitive = { typeid: 'SimpleTest:DefaultPrimitive-1.0.0', properties: [ { id: 'num', typeid: 'Uint32', value: 111 }, - { id: 'bool', typeid: 'Bool', value: true } - ] + { id: 'bool', typeid: 'Bool', value: true }, + ], }; PropertyFactory.register(DefaultPrimitive); @@ -1655,12 +1654,12 @@ describe('PropertyFactory', function () { expect(instance.get('bool').getValue()).to.equal(true); }); - it('should set a default value for a string property', function () { + it('should set a default value for a string property', function() { var DefaultString = { typeid: 'SimpleTest:DefaultString-1.0.0', properties: [ - { id: 'string', typeid: 'String', value: 'I am a string' } - ] + { id: 'string', typeid: 'String', value: 'I am a string' }, + ], }; PropertyFactory.register(DefaultString); @@ -1669,12 +1668,12 @@ describe('PropertyFactory', function () { expect(instance.get('string').getValue()).to.equal('I am a string'); }); - it('should set a default value for a primitive array property', function () { + it('should set a default value for a primitive array property', function() { var DefaultArray = { typeid: 'SimpleTest:DefaultArray-1.0.0', properties: [ - { id: 'array', typeid: 'Int32', value: [111, 222], context: 'array' } - ] + { id: 'array', typeid: 'Int32', value: [111, 222], context: 'array' }, + ], }; PropertyFactory.register(DefaultArray); @@ -1684,12 +1683,12 @@ describe('PropertyFactory', function () { expect(instance.get('array').get(1)).to.equal(222); }); - it('should set a default value for a typed array property', function () { + it('should set a default value for a typed array property', function() { var DefaultTypedArrayEntry = { typeid: 'SimpleTest:DefaultTypedArrayEntry-1.0.0', properties: [ - { id: 'string', typeid: 'String' } - ] + { id: 'string', typeid: 'String' }, + ], }; var DefaultTypedArray = { @@ -1697,9 +1696,9 @@ describe('PropertyFactory', function () { properties: [ { id: 'array', typeid: 'SimpleTest:DefaultTypedArrayEntry-1.0.0', context: 'array', value: [ - { string: 'I am string 1' }, { string: 'I am string 2' }] - } - ] + { string: 'I am string 1' }, { string: 'I am string 2' }], + }, + ], }; PropertyFactory.register(DefaultTypedArrayEntry); @@ -1710,7 +1709,7 @@ describe('PropertyFactory', function () { expect(instance.get('array').get(1).get('string').value).to.equal('I am string 2'); }); - it('should set a default value for an enum property', function () { + it('should set a default value for an enum property', function() { var DefaultEnum = { typeid: 'SimpleTest:DefaultEnum-1.0.0', properties: [ @@ -1718,10 +1717,10 @@ describe('PropertyFactory', function () { id: 'enum', typeid: 'Enum', properties: [ { id: 'solid', value: 111 }, { id: 'dashed', value: 222 }, - { id: 'dotted', value: 333 } - ], value: 'dashed' - } - ] + { id: 'dotted', value: 333 }, + ], value: 'dashed', + }, + ], }; PropertyFactory.register(DefaultEnum); @@ -1730,17 +1729,17 @@ describe('PropertyFactory', function () { expect(instance.get('enum').getValue()).to.equal(222); }); - it('should set a default value for an untyped property, parent default value has precedence', function () { + it('should set a default value for an untyped property, parent default value has precedence', function() { var DefaultUntyped = { typeid: 'SimpleTest:DefaultUntyped-1.0.0', properties: [ { id: 'untyped', properties: [ { id: 'num', typeid: 'Uint32', value: 222 }, - { id: 'string', typeid: 'String', value: 'I should not be set' } - ], value: { string: 'I am a string', num: 111 } - } - ] + { id: 'string', typeid: 'String', value: 'I should not be set' }, + ], value: { string: 'I am a string', num: 111 }, + }, + ], }; PropertyFactory.register(DefaultUntyped); @@ -1751,17 +1750,17 @@ describe('PropertyFactory', function () { expect(instance.get('untyped').get('num').getValue()).to.equal(111); }); - it('should set a default value for a template, parent default value has precedence', function () { + it('should set a default value for a template, parent default value has precedence', function() { var DefaultTemplateEntry = { typeid: 'SimpleTest:DefaultTemplateEntry-1.0.0', properties: [ { id: 'num', typeid: 'Uint32', value: '222' }, { id: 'dynamic', properties: [ - { id: 'dynamic_string', typeid: 'String' } - ], value: { dynamic_string: 'I should not be set' } - } - ] + { id: 'dynamic_string', typeid: 'String' }, + ], value: { dynamic_string: 'I should not be set' }, + }, + ], }; var DefaultTemplate = { @@ -1769,10 +1768,10 @@ describe('PropertyFactory', function () { properties: [ { id: 'template', typeid: 'SimpleTest:DefaultTemplateEntry-1.0.0', value: { - num: 111, dynamic: { dynamic_string: 'I am a string' } - } - } - ] + num: 111, dynamic: { dynamic_string: 'I am a string' }, + }, + }, + ], }; PropertyFactory.register(DefaultTemplateEntry); @@ -1784,13 +1783,13 @@ describe('PropertyFactory', function () { expect(instance.get('template').get('dynamic').get('dynamic_string').getValue()).to.equal('I am a string'); }); - it('should set a default value for a set', function () { + it('should set a default value for a set', function() { var DefaultSetEntry = { typeid: 'SimpleTest:DefaultSetEntry-1.0.0', inherits: ['NamedProperty'], properties: [ - { id: 'string', typeid: 'String' } - ] + { id: 'string', typeid: 'String' }, + ], }; var DefaultSet = { @@ -1799,10 +1798,10 @@ describe('PropertyFactory', function () { { id: 'set', typeid: 'SimpleTest:DefaultSetEntry-1.0.0', context: 'set', value: [ { string: 'I am a string 1' }, - { string: 'I am a string 2' } - ] - } - ] + { string: 'I am a string 2' }, + ], + }, + ], }; PropertyFactory.register(DefaultSetEntry); @@ -1815,17 +1814,17 @@ describe('PropertyFactory', function () { expect(instance.get('set').getAsArray()[1].get('string').getValue()).to.equal('I am a string 2'); }); - it('should set a default value for a primitive map', function () { + it('should set a default value for a primitive map', function() { var DefaultPrimitiveMap = { typeid: 'SimpleTest:DefaultPrimitiveMap-1.0.0', properties: [ { id: 'map', typeid: 'Int32', context: 'map', value: { key1: 111, - key2: 222 - } - } - ] + key2: 222, + }, + }, + ], }; PropertyFactory.register(DefaultPrimitiveMap); @@ -1836,13 +1835,13 @@ describe('PropertyFactory', function () { expect(instance.get('map').getEntriesReadOnly().key2).to.equal(222); }); - it('should set a default value for a typed map', function () { + it('should set a default value for a typed map', function() { var DefaultTypedMapEntry = { typeid: 'SimpleTest:DefaultTypedMapEntry-1.0.0', inherits: ['NamedProperty'], properties: [ - { id: 'string', typeid: 'String' } - ] + { id: 'string', typeid: 'String' }, + ], }; var DefaultTypedMap = { @@ -1851,10 +1850,10 @@ describe('PropertyFactory', function () { { id: 'map', typeid: 'SimpleTest:DefaultTypedMapEntry-1.0.0', context: 'map', value: { key1: { string: 'I am a string 1' }, - key2: { string: 'I am a string 2' } - } - } - ] + key2: { string: 'I am a string 2' }, + }, + }, + ], }; PropertyFactory.register(DefaultTypedMapEntry); @@ -1866,30 +1865,30 @@ describe('PropertyFactory', function () { expect(instance.get('map').getEntriesReadOnly().key2.get('string').getValue()).to.equal('I am a string 2'); }); - it('initial values should override default values', function () { + it('initial values should override default values', function() { var DefaultInitialValue = { typeid: 'SimpleTest:DefaultInitialValue-1.0.0', properties: [ - { id: 'string', typeid: 'String', value: 'I should not be set' } - ] + { id: 'string', typeid: 'String', value: 'I should not be set' }, + ], }; PropertyFactory.register(DefaultInitialValue); var instance = PropertyFactory.create('SimpleTest:DefaultInitialValue-1.0.0', null, { - string: 'I am a string' + string: 'I am a string', }); expect(instance.get('string').getValue()).to.equal('I am a string'); }); - describe('#Polymorphic', function () { + describe('#Polymorphic', function() { var DefaultPolyBase = { typeid: 'SimpleTest:DefaultPolyBase-1.0.0', inherits: ['NamedProperty'], properties: [ - { id: 'num', typeid: 'Uint32', value: 111 } - ] + { id: 'num', typeid: 'Uint32', value: 111 }, + ], }; var DefaultPolySub = { @@ -1897,8 +1896,8 @@ describe('PropertyFactory', function () { inherits: 'SimpleTest:DefaultPolyBase-1.0.0', properties: [ { id: 'num', typeid: 'Uint32', value: 222 }, - { id: 'str', typeid: 'String', value: 'Sub' } - ] + { id: 'str', typeid: 'String', value: 'Sub' }, + ], }; var DefaultPolySubSub = { @@ -1907,30 +1906,30 @@ describe('PropertyFactory', function () { properties: [ { id: 'num', typeid: 'Uint32', value: 333 }, { id: 'num2', typeid: 'Uint32', value: 111 }, - { id: 'str', typeid: 'String', value: 'SubSub' } - ] + { id: 'str', typeid: 'String', value: 'SubSub' }, + ], }; - beforeEach(function () { + beforeEach(function() { PropertyFactory._clear(); PropertyFactory.register(DefaultPolyBase); PropertyFactory.register(DefaultPolySub); PropertyFactory.register(DefaultPolySubSub); }); - it('should set default polymorphic values for non-primitive properties', function () { + it('should set default polymorphic values for non-primitive properties', function() { var DefaultPolyContainer = { typeid: 'SimpleTest:DefaultPolyContainer-1.0.0', properties: [ { id: 'polySub', typeid: 'SimpleTest:DefaultPolyBase-1.0.0', - typedValue: { typeid: 'SimpleTest:DefaultPolySub-1.0.0', value: { num: 333, str: 'PolySub' } } + typedValue: { typeid: 'SimpleTest:DefaultPolySub-1.0.0', value: { num: 333, str: 'PolySub' } }, }, { id: 'polySubSub', typeid: 'SimpleTest:DefaultPolyBase-1.0.0', - typedValue: { typeid: 'SimpleTest:DefaultPolySubSub-1.0.0', value: { num: 444, str: 'PolySubSub' } } - } - ] + typedValue: { typeid: 'SimpleTest:DefaultPolySubSub-1.0.0', value: { num: 444, str: 'PolySubSub' } }, + }, + ], }; PropertyFactory.register(DefaultPolyContainer); @@ -1944,13 +1943,13 @@ describe('PropertyFactory', function () { expect(instance.get('polySubSub').get('num2').getValue()).to.equal(111); }); - it('should fail when setting a default typedValue that doesnt have a typeid.', function () { + it('should fail when setting a default typedValue that doesnt have a typeid.', function() { var DefaultPolyNoTypeIdContainer = { typeid: 'SimpleTest:DefaultPolyNoTypeIdContainer-1.0.0', properties: [{ id: 'polySub', typeid: 'SimpleTest:DefaultPolyBase-1.0.0', - typedValue: { value: { num: 333, str: 'PolySub' } } - }] + typedValue: { value: { num: 333, str: 'PolySub' } }, + }], }; PropertyFactory.register(DefaultPolyNoTypeIdContainer); @@ -1959,7 +1958,7 @@ describe('PropertyFactory', function () { .to.throw(MSG.FIELD_TYPEID_IS_REQUIRED + 'typedValue SimpleTest:DefaultPolyBase-1.0.0'); }); - it('should set a default polymorphic value for a non-primitive array', function () { + it('should set a default polymorphic value for a non-primitive array', function() { var DefaultPolyArrayContainer = { typeid: 'SimpleTest:DefaultPolyArrayContainer-1.0.0', properties: [ @@ -1967,10 +1966,10 @@ describe('PropertyFactory', function () { id: 'array', typeid: 'SimpleTest:DefaultPolyBase-1.0.0', context: 'array', typedValue: [ { typeid: 'SimpleTest:DefaultPolySub-1.0.0' }, { typeid: 'SimpleTest:DefaultPolySub-1.0.0', value: { str: 'ArrSub' } }, - { typeid: 'SimpleTest:DefaultPolySubSub-1.0.0', value: { str: 'ArrSubSub' } } - ] - } - ] + { typeid: 'SimpleTest:DefaultPolySubSub-1.0.0', value: { str: 'ArrSubSub' } }, + ], + }, + ], }; PropertyFactory.register(DefaultPolyArrayContainer); @@ -1985,7 +1984,7 @@ describe('PropertyFactory', function () { expect(instance.get('array').get(2).get('num2').value).to.equal(111); }); - it('should set a default polymorphic value for a non-primitive set', function () { + it('should set a default polymorphic value for a non-primitive set', function() { var DefaultPolySetContainer = { typeid: 'SimpleTest:DefaultPolySetContainer-1.0.0', properties: [ @@ -1993,10 +1992,10 @@ describe('PropertyFactory', function () { id: 'set', typeid: 'SimpleTest:DefaultPolyBase-1.0.0', context: 'set', typedValue: [ { typeid: 'SimpleTest:DefaultPolySub-1.0.0' }, { typeid: 'SimpleTest:DefaultPolySub-1.0.0', value: { str: 'ArrSub' } }, - { typeid: 'SimpleTest:DefaultPolySubSub-1.0.0', value: { str: 'ArrSubSub' } } - ] - } - ] + { typeid: 'SimpleTest:DefaultPolySubSub-1.0.0', value: { str: 'ArrSubSub' } }, + ], + }, + ], }; PropertyFactory.register(DefaultPolySetContainer); @@ -2013,7 +2012,7 @@ describe('PropertyFactory', function () { expect(instance.get('set').getAsArray()[2].get('num2').getValue()).to.equal(111); }); - it('should set a default polymorphic value for a non-primitive map', function () { + it('should set a default polymorphic value for a non-primitive map', function() { var DefaultPolyMapContainer = { typeid: 'SimpleTest:DefaultPolyMapContainer-1.0.0', properties: [ @@ -2021,10 +2020,10 @@ describe('PropertyFactory', function () { id: 'map', typeid: 'SimpleTest:DefaultPolyBase-1.0.0', context: 'map', typedValue: { key1: { typeid: 'SimpleTest:DefaultPolySub-1.0.0' }, key2: { typeid: 'SimpleTest:DefaultPolySub-1.0.0', value: { str: 'ArrSub' } }, - key3: { typeid: 'SimpleTest:DefaultPolySubSub-1.0.0', value: { str: 'ArrSubSub' } } - } - } - ] + key3: { typeid: 'SimpleTest:DefaultPolySubSub-1.0.0', value: { str: 'ArrSubSub' } }, + }, + }, + ], }; PropertyFactory.register(DefaultPolyMapContainer); @@ -2040,12 +2039,12 @@ describe('PropertyFactory', function () { expect(instance.get('map').getEntriesReadOnly().key3.get('num2').getValue()).to.equal(111); }); - it('should fail when setting default polymorphic values not derived from base type', function () { + it('should fail when setting default polymorphic values not derived from base type', function() { var DefaultPoly = { typeid: 'SimpleTest:DefaultPoly-1.0.0', properties: [ - { id: 'num', typeid: 'Uint32', value: 111 } - ] + { id: 'num', typeid: 'Uint32', value: 111 }, + ], }; var DefaultPolyUnderivedContainer = { @@ -2053,9 +2052,9 @@ describe('PropertyFactory', function () { properties: [ { id: 'poly', typeid: 'SimpleTest:DefaultPolyBase-1.0.0', - typedValue: { typeid: 'SimpleTest:DefaultPoly-1.0.0', value: { num: 333 } } - } - ] + typedValue: { typeid: 'SimpleTest:DefaultPoly-1.0.0', value: { num: 333 } }, + }, + ], }; PropertyFactory.register(DefaultPoly); @@ -2065,15 +2064,15 @@ describe('PropertyFactory', function () { .to.throw(MSG.TYPED_VALUES_MUST_DERIVE_FROM_BASE_TYPE + 'SimpleTest:DefaultPoly-1.0.0'); }); - it('@bugfix should use default value when value field is missing', function () { + it('@bugfix should use default value when value field is missing', function() { var DefaultPoly = { typeid: 'SimpleTest:PolyWithNoValue-1.0.0', constants: [ { id: 'type', typeid: 'SimpleTest:DefaultPolyBase-1.0.0', - typedValue: { typeid: 'SimpleTest:DefaultPolyBase-1.0.0' } - } - ] + typedValue: { typeid: 'SimpleTest:DefaultPolyBase-1.0.0' }, + }, + ], }; PropertyFactory.register(DefaultPoly); @@ -2082,12 +2081,12 @@ describe('PropertyFactory', function () { expect(prop.get('type').get('num').value).to.equal(111); }); - it('should fail when setting a typedValue to a primitive.', function () { + it('should fail when setting a typedValue to a primitive.', function() { var DefaultPrimitiveArrayPoly = { typeid: 'SimpleTest:DefaultPrimitivePoly-1.0.0', properties: [{ - id: 'int', typeid: 'Int32', typedValue: { typeid: 'Int32', value: 123 } - }] + id: 'int', typeid: 'Int32', typedValue: { typeid: 'Int32', value: 123 }, + }], }; PropertyFactory.register(DefaultPrimitiveArrayPoly); @@ -2096,12 +2095,12 @@ describe('PropertyFactory', function () { .to.throw(MSG.TYPED_VALUES_FOR_PRIMITIVES_NOT_SUPPORTED + 'int'); }); - it('should fail when setting a typedValue to a primitive array.', function () { + it('should fail when setting a typedValue to a primitive array.', function() { var DefaultPrimitiveArrayPoly = { typeid: 'SimpleTest:DefaultPrimitiveArrayPoly-1.0.0', properties: [{ - id: 'array', context: 'array', typeid: 'Int32', typedValue: [{ typeid: 'Int32', value: 123 }] - }] + id: 'array', context: 'array', typeid: 'Int32', typedValue: [{ typeid: 'Int32', value: 123 }], + }], }; PropertyFactory.register(DefaultPrimitiveArrayPoly); @@ -2110,15 +2109,15 @@ describe('PropertyFactory', function () { .to.throw(MSG.TYPED_VALUES_FOR_PRIMITIVES_NOT_SUPPORTED + 'array'); }); - it('should fail when setting a typedValue to a primitive map.', function () { + it('should fail when setting a typedValue to a primitive map.', function() { var DefaultPrimitiveMapPoly = { typeid: 'SimpleTest:DefaultPrimitiveMapPoly-1.0.0', properties: [{ id: 'map', context: 'map', typeid: 'Int32', typedValue: { key1: { typeid: 'Int32', value: 1 }, - key2: { typeid: 'Int32', value: 2 } - } - }] + key2: { typeid: 'Int32', value: 2 }, + }, + }], }; PropertyFactory.register(DefaultPrimitiveMapPoly); @@ -2129,14 +2128,14 @@ describe('PropertyFactory', function () { }); }); - describe('Constants', function () { - it('should set constant properties as readonly', function () { + describe('Constants', function() { + it('should set constant properties as readonly', function() { var ConstantReadonly = { typeid: 'SimpleTest:ConstantReadonly-1.0.0', constants: [ - { id: 'num', typeid: 'Uint32', value: 111 } + { id: 'num', typeid: 'Uint32', value: 111 }, ], - properties: [{ id: 'default', typeid: 'Uint32' }] + properties: [{ id: 'default', typeid: 'Uint32' }], }; PropertyFactory.register(ConstantReadonly); @@ -2151,17 +2150,17 @@ describe('PropertyFactory', function () { instance.get('num'), 1111)).to.throw(MSG.MODIFICATION_OF_CONSTANT_PROPERTY); }); - it('should set constant child properties as readonly', function () { + it('should set constant child properties as readonly', function() { var ConstantChildReadonlyEntry = { typeid: 'SimpleTest:ConstantChildReadonlyEntry-1.0.0', properties: [ { id: 'num', typeid: 'Uint32' }, { id: 'dynamic', properties: [ - { id: 'dynamic_string', typeid: 'String' } - ] - } - ] + { id: 'dynamic_string', typeid: 'String' }, + ], + }, + ], }; var ConstantChildReadonly = { @@ -2169,11 +2168,11 @@ describe('PropertyFactory', function () { constants: [ { id: 'template', typeid: 'SimpleTest:ConstantChildReadonlyEntry-1.0.0', value: { - num: 111, dynamic: { dynamic_string: 'I am a string' } - } - } + num: 111, dynamic: { dynamic_string: 'I am a string' }, + }, + }, ], - properties: [{ id: 'default', typeid: 'Uint32' }] + properties: [{ id: 'default', typeid: 'Uint32' }], }; PropertyFactory.register(ConstantChildReadonlyEntry); @@ -2196,14 +2195,14 @@ describe('PropertyFactory', function () { MSG.MODIFICATION_OF_CONSTANT_PROPERTY); }); - it('should support primitive constants', function () { + it('should support primitive constants', function() { var ConstantPrimitive = { typeid: 'SimpleTest:ConstantPrimitive-1.0.0', constants: [ { id: 'num', typeid: 'Uint32', value: 111 }, - { id: 'bool', typeid: 'Bool', value: true } + { id: 'bool', typeid: 'Bool', value: true }, ], - properties: [{ id: 'default', typeid: 'Uint32' }] + properties: [{ id: 'default', typeid: 'Uint32' }], }; PropertyFactory.register(ConstantPrimitive); @@ -2214,22 +2213,22 @@ describe('PropertyFactory', function () { expect(instance.get('bool').getValue()).to.equal(true); }); - it('should support typed constants', function () { + it('should support typed constants', function() { var ConstantEntry = { typeid: 'SimpleTest:ConstantEntry-1.0.0', constants: [ { id: 'num', typeid: 'Uint32', value: 111 }, - { id: 'bool', typeid: 'Bool', value: true } + { id: 'bool', typeid: 'Bool', value: true }, ], - properties: [{ id: 'default', typeid: 'Uint32' }] + properties: [{ id: 'default', typeid: 'Uint32' }], }; var ConstantTyped = { typeid: 'SimpleTest:ConstantTyped-1.0.0', constants: [ - { id: 'entry', typeid: 'SimpleTest:ConstantEntry-1.0.0', value: { num: 222, bool: false } } + { id: 'entry', typeid: 'SimpleTest:ConstantEntry-1.0.0', value: { num: 222, bool: false } }, ], - properties: [{ id: 'default2', typeid: 'Uint32' }] + properties: [{ id: 'default2', typeid: 'Uint32' }], }; PropertyFactory.register(ConstantEntry); @@ -2241,13 +2240,13 @@ describe('PropertyFactory', function () { expect(instance.get('entry').get('bool').getValue()).to.equal(false); }); - it('should support string constants', function () { + it('should support string constants', function() { var ConstantString = { typeid: 'SimpleTest:ConstantString-1.0.0', constants: [ - { id: 'string', typeid: 'String', value: 'I am a string' } + { id: 'string', typeid: 'String', value: 'I am a string' }, ], - properties: [{ id: 'default', typeid: 'Uint32' }] + properties: [{ id: 'default', typeid: 'Uint32' }], }; PropertyFactory.register(ConstantString); @@ -2257,13 +2256,13 @@ describe('PropertyFactory', function () { expect(instance.get('string').getValue()).to.equal('I am a string'); }); - it('should support primitive array constants', function () { + it('should support primitive array constants', function() { var ConstantArray = { typeid: 'SimpleTest:ConstantArray-1.0.0', constants: [ - { id: 'array', typeid: 'Int32', value: [111, 222], context: 'array' } + { id: 'array', typeid: 'Int32', value: [111, 222], context: 'array' }, ], - properties: [{ id: 'default', typeid: 'Uint32' }] + properties: [{ id: 'default', typeid: 'Uint32' }], }; PropertyFactory.register(ConstantArray); @@ -2273,12 +2272,12 @@ describe('PropertyFactory', function () { expect(instance.get('array').get(1)).to.equal(222); }); - it('should support typed array constants', function () { + it('should support typed array constants', function() { var ConstantTypedArrayEntry = { typeid: 'SimpleTest:ConstantTypedArrayEntry-1.0.0', properties: [ - { id: 'string', typeid: 'String' } - ] + { id: 'string', typeid: 'String' }, + ], }; var ConstantTypedArray = { @@ -2286,9 +2285,9 @@ describe('PropertyFactory', function () { constants: [ { id: 'array', typeid: 'SimpleTest:ConstantTypedArrayEntry-1.0.0', context: 'array', value: [ - { string: 'I am string 1' }, { string: 'I am string 2' }] - } - ] + { string: 'I am string 1' }, { string: 'I am string 2' }], + }, + ], }; PropertyFactory.register(ConstantTypedArrayEntry); @@ -2299,17 +2298,17 @@ describe('PropertyFactory', function () { expect(instance.get('array').get(1).get('string').value).to.equal('I am string 2'); }); - it('should support template constants', function () { + it('should support template constants', function() { var ConstantTemplateEntry = { typeid: 'SimpleTest:ConstantTemplateEntry-1.0.0', properties: [ { id: 'num', typeid: 'Uint32' }, { id: 'dynamic', properties: [ - { id: 'dynamic_string', typeid: 'String' } - ] - } - ] + { id: 'dynamic_string', typeid: 'String' }, + ], + }, + ], }; var ConstantTemplate = { @@ -2317,11 +2316,11 @@ describe('PropertyFactory', function () { constants: [ { id: 'template', typeid: 'SimpleTest:ConstantTemplateEntry-1.0.0', value: { - num: 111, dynamic: { dynamic_string: 'I am a string' } - } - } + num: 111, dynamic: { dynamic_string: 'I am a string' }, + }, + }, ], - properties: [{ id: 'default', typeid: 'Uint32' }] + properties: [{ id: 'default', typeid: 'Uint32' }], }; PropertyFactory.register(ConstantTemplateEntry); @@ -2333,13 +2332,13 @@ describe('PropertyFactory', function () { expect(instance.get('template').get('dynamic').get('dynamic_string').getValue()).to.equal('I am a string'); }); - it('should support set constants', function () { + it('should support set constants', function() { var ConstantSetEntry = { typeid: 'SimpleTest:ConstantSetEntry-1.0.0', inherits: ['NamedProperty'], properties: [ - { id: 'string', typeid: 'String' } - ] + { id: 'string', typeid: 'String' }, + ], }; var ConstantSet = { @@ -2348,11 +2347,11 @@ describe('PropertyFactory', function () { { id: 'set', typeid: 'SimpleTest:ConstantSetEntry-1.0.0', context: 'set', value: [ { string: 'I am a string 1' }, - { string: 'I am a string 2' } - ] - } + { string: 'I am a string 2' }, + ], + }, ], - properties: [{ id: 'default', typeid: 'Uint32' }] + properties: [{ id: 'default', typeid: 'Uint32' }], }; PropertyFactory.register(ConstantSetEntry); @@ -2369,18 +2368,18 @@ describe('PropertyFactory', function () { expect(instance.get('set') === instance2.get('set')).to.be.true; }); - it('should support primitive map constants', function () { + it('should support primitive map constants', function() { var ConstantPrimitiveMap = { typeid: 'SimpleTest:ConstantPrimitiveMap-1.0.0', constants: [ { id: 'map', typeid: 'Int32', context: 'map', value: { key1: 111, - key2: 222 - } - } + key2: 222, + }, + }, ], - properties: [{ id: 'default', typeid: 'Uint32' }] + properties: [{ id: 'default', typeid: 'Uint32' }], }; PropertyFactory.register(ConstantPrimitiveMap); @@ -2391,13 +2390,13 @@ describe('PropertyFactory', function () { expect(instance.get('map').getEntriesReadOnly().key2).to.equal(222); }); - it('should support typed map constants', function () { + it('should support typed map constants', function() { var ConstantTypedMapEntry = { typeid: 'SimpleTest:ConstantTypedMapEntry-1.0.0', inherits: ['NamedProperty'], properties: [ - { id: 'string', typeid: 'String' } - ] + { id: 'string', typeid: 'String' }, + ], }; var ConstantTypedMap = { @@ -2406,11 +2405,11 @@ describe('PropertyFactory', function () { { id: 'map', typeid: 'SimpleTest:ConstantTypedMapEntry-1.0.0', context: 'map', value: { key1: { string: 'I am a string 1' }, - key2: { string: 'I am a string 2' } - } - } + key2: { string: 'I am a string 2' }, + }, + }, ], - properties: [{ id: 'default', typeid: 'Uint32' }] + properties: [{ id: 'default', typeid: 'Uint32' }], }; PropertyFactory.register(ConstantTypedMapEntry); @@ -2423,7 +2422,7 @@ describe('PropertyFactory', function () { expect(instance.get('map').getEntriesReadOnly().key2.get('string').getValue()).to.equal('I am a string 2'); }); - it('should support map constants with templateid keys', function () { + it('should support map constants with templateid keys', function() { var ConstantTemplate = { typeid: 'SimpleTest:ConstantTemplate-1.0.0', constants: [ @@ -2432,10 +2431,10 @@ describe('PropertyFactory', function () { typeid: 'Int32', context: 'map', contextKeyType: 'typeid', - value: { 'SimpleTest:ConstantTemplate1-1.0.0': 1, 'SimpleTest:ConstantTemplate2-1.0.0': -1 } - } + value: { 'SimpleTest:ConstantTemplate1-1.0.0': 1, 'SimpleTest:ConstantTemplate2-1.0.0': -1 }, + }, ], - properties: [{ id: 'default', typeid: 'Uint32' }] + properties: [{ id: 'default', typeid: 'Uint32' }], }; PropertyFactory._reregister(ConstantTemplate); var instance = PropertyFactory.create('SimpleTest:ConstantTemplate-1.0.0'); @@ -2445,15 +2444,15 @@ describe('PropertyFactory', function () { expect(instance.get('map').get('SimpleTest:ConstantTemplate2-1.0.0')).to.equal(-1); }); - it('should support constants with no value defined', function () { + it('should support constants with no value defined', function() { var ConstantNoValueEntry = { typeid: 'SimpleTest:ConstantNoValueEntry-1.0.0', inherits: ['NamedProperty'], constants: [ { id: 'num', typeid: 'Int16' }, { id: 'bool', typeid: 'Bool' }, - { id: 'string', typeid: 'String' } - ] + { id: 'string', typeid: 'String' }, + ], }; var ConstantNoValue = { @@ -2465,8 +2464,8 @@ describe('PropertyFactory', function () { { id: 'array', typeid: 'Int16', context: 'array' }, { id: 'array_typed', typeid: 'SimpleTest:ConstantNoValueEntry-1.0.0', context: 'array' }, { id: 'set', typeid: 'SimpleTest:ConstantNoValueEntry-1.0.0', context: 'set' }, - { id: 'map', typeid: 'SimpleTest:ConstantNoValueEntry-1.0.0', context: 'map' } - ] + { id: 'map', typeid: 'SimpleTest:ConstantNoValueEntry-1.0.0', context: 'map' }, + ], }; var ConstantNoValueInherited = { @@ -2480,20 +2479,20 @@ describe('PropertyFactory', function () { { id: 'array_typed', typeid: 'SimpleTest:ConstantNoValueEntry-1.0.0', context: 'array', value: [ { num: 100 }, - { num: 200, string: 'I am a string 2', bool: true }] + { num: 200, string: 'I am a string 2', bool: true }], }, { id: 'set', typeid: 'SimpleTest:ConstantNoValueEntry-1.0.0', context: 'set', value: [ { num: 100 }, - { num: 200, string: 'I am a string 2', bool: true }] + { num: 200, string: 'I am a string 2', bool: true }], }, { id: 'map', typeid: 'SimpleTest:ConstantNoValueEntry-1.0.0', context: 'map', value: { key1: { num: 100 }, - key2: { num: 200, string: 'I am a string 2', bool: true } - } - } - ] + key2: { num: 200, string: 'I am a string 2', bool: true }, + }, + }, + ], }; PropertyFactory.register(ConstantNoValueEntry); @@ -2542,13 +2541,13 @@ describe('PropertyFactory', function () { expect(map.key2.get('bool').getValue()).to.equal(true); }); - describe('#Polymorphic', function () { + describe('#Polymorphic', function() { var ConstantPolyBase = { typeid: 'SimpleTest:ConstantPolyBase-1.0.0', inherits: ['NamedProperty'], constants: [ - { id: 'num', typeid: 'Uint32', value: 111 } - ] + { id: 'num', typeid: 'Uint32', value: 111 }, + ], }; var ConstantPolySub = { @@ -2556,8 +2555,8 @@ describe('PropertyFactory', function () { inherits: 'SimpleTest:ConstantPolyBase-1.0.0', constants: [ { id: 'num', typeid: 'Uint32', value: 222 }, - { id: 'str', typeid: 'String', value: 'Sub' } - ] + { id: 'str', typeid: 'String', value: 'Sub' }, + ], }; var ConstantPolySubSub = { @@ -2566,30 +2565,30 @@ describe('PropertyFactory', function () { constants: [ { id: 'num', typeid: 'Uint32', value: 333 }, { id: 'num2', typeid: 'Uint32', value: 111 }, - { id: 'str', typeid: 'String', value: 'SubSub' } - ] + { id: 'str', typeid: 'String', value: 'SubSub' }, + ], }; - beforeEach(function () { + beforeEach(function() { PropertyFactory._clear(); PropertyFactory.register(ConstantPolyBase); PropertyFactory.register(ConstantPolySub); PropertyFactory.register(ConstantPolySubSub); }); - it('should set constant polymorphic values for non-primitive constants', function () { + it('should set constant polymorphic values for non-primitive constants', function() { var ConstantPolyContainer = { typeid: 'SimpleTest:ConstantPolyContainer-1.0.0', constants: [ { id: 'polySub', typeid: 'SimpleTest:ConstantPolyBase-1.0.0', - typedValue: { typeid: 'SimpleTest:ConstantPolySub-1.0.0', value: { num: 333, str: 'PolySub' } } + typedValue: { typeid: 'SimpleTest:ConstantPolySub-1.0.0', value: { num: 333, str: 'PolySub' } }, }, { id: 'polySubSub', typeid: 'SimpleTest:ConstantPolyBase-1.0.0', - typedValue: { typeid: 'SimpleTest:ConstantPolySubSub-1.0.0', value: { num: 444, str: 'PolySubSub' } } - } - ] + typedValue: { typeid: 'SimpleTest:ConstantPolySubSub-1.0.0', value: { num: 444, str: 'PolySubSub' } }, + }, + ], }; PropertyFactory.register(ConstantPolyContainer); @@ -2603,13 +2602,13 @@ describe('PropertyFactory', function () { expect(instance.get('polySubSub').get('num2').getValue()).to.equal(111); }); - it('should pass when setting a constant typedValue that doesnt have a value.', function () { + it('should pass when setting a constant typedValue that doesnt have a value.', function() { var ConstantPolyNoValueContainer = { typeid: 'SimpleTest:ConstantPolyNoValueContainer-1.0.0', constants: [{ id: 'polySub', typeid: 'SimpleTest:ConstantPolyBase-1.0.0', - typedValue: { typeid: 'SimpleTest:ConstantPolySub-1.0.0' } - }] + typedValue: { typeid: 'SimpleTest:ConstantPolySub-1.0.0' }, + }], }; PropertyFactory.register(ConstantPolyNoValueContainer); @@ -2618,13 +2617,13 @@ describe('PropertyFactory', function () { expect(prop.get('polySub').get('str').value).to.equal('Sub'); }); - it('should fail when setting a constant typedValue that doesnt have a typeid.', function () { + it('should fail when setting a constant typedValue that doesnt have a typeid.', function() { var ConstantPolyNoTypeIdContainer = { typeid: 'SimpleTest:ConstantPolyNoTypeIdContainer-1.0.0', constants: [{ id: 'polySub', typeid: 'SimpleTest:ConstantPolyBase-1.0.0', - typedValue: { value: { num: 333, str: 'PolySub' } } - }] + typedValue: { value: { num: 333, str: 'PolySub' } }, + }], }; PropertyFactory.register(ConstantPolyNoTypeIdContainer); @@ -2633,7 +2632,7 @@ describe('PropertyFactory', function () { .to.throw(MSG.FIELD_TYPEID_IS_REQUIRED + 'typedValue SimpleTest:ConstantPolyBase-1.0.0'); }); - it('should set a constant polymorphic value for a non-primitive array', function () { + it('should set a constant polymorphic value for a non-primitive array', function() { var ConstantPolyArrayContainer = { typeid: 'SimpleTest:ConstantPolyArrayContainer-1.0.0', constants: [ @@ -2641,10 +2640,10 @@ describe('PropertyFactory', function () { id: 'array', typeid: 'SimpleTest:ConstantPolyBase-1.0.0', context: 'array', typedValue: [ { typeid: 'SimpleTest:ConstantPolySub-1.0.0' }, { typeid: 'SimpleTest:ConstantPolySub-1.0.0', value: { str: 'ArrSub' } }, - { typeid: 'SimpleTest:ConstantPolySubSub-1.0.0', value: { str: 'ArrSubSub' } } - ] - } - ] + { typeid: 'SimpleTest:ConstantPolySubSub-1.0.0', value: { str: 'ArrSubSub' } }, + ], + }, + ], }; PropertyFactory.register(ConstantPolyArrayContainer); @@ -2659,7 +2658,7 @@ describe('PropertyFactory', function () { expect(instance.get('array').get(2).get('num2').value).to.equal(111); }); - it('should set a constant polymorphic value for a non-primitive set', function () { + it('should set a constant polymorphic value for a non-primitive set', function() { var ConstantPolySetContainer = { typeid: 'SimpleTest:ConstantPolySetContainer-1.0.0', constants: [ @@ -2667,10 +2666,10 @@ describe('PropertyFactory', function () { id: 'set', typeid: 'SimpleTest:ConstantPolyBase-1.0.0', context: 'set', typedValue: [ { typeid: 'SimpleTest:ConstantPolySub-1.0.0' }, { typeid: 'SimpleTest:ConstantPolySub-1.0.0', value: { str: 'ArrSub' } }, - { typeid: 'SimpleTest:ConstantPolySubSub-1.0.0', value: { str: 'ArrSubSub' } } - ] - } - ] + { typeid: 'SimpleTest:ConstantPolySubSub-1.0.0', value: { str: 'ArrSubSub' } }, + ], + }, + ], }; PropertyFactory.register(ConstantPolySetContainer); @@ -2687,7 +2686,7 @@ describe('PropertyFactory', function () { expect(instance.get('set').getAsArray()[2].get('num2').getValue()).to.equal(111); }); - it('should set a constant polymorphic value for a non-primitive map', function () { + it('should set a constant polymorphic value for a non-primitive map', function() { var ConstantPolyMapContainer = { typeid: 'SimpleTest:ConstantPolyMapContainer-1.0.0', constants: [ @@ -2695,10 +2694,10 @@ describe('PropertyFactory', function () { id: 'map', typeid: 'SimpleTest:ConstantPolyBase-1.0.0', context: 'map', typedValue: { key1: { typeid: 'SimpleTest:ConstantPolySub-1.0.0' }, key2: { typeid: 'SimpleTest:ConstantPolySub-1.0.0', value: { str: 'ArrSub' } }, - key3: { typeid: 'SimpleTest:ConstantPolySubSub-1.0.0', value: { str: 'ArrSubSub' } } - } - } - ] + key3: { typeid: 'SimpleTest:ConstantPolySubSub-1.0.0', value: { str: 'ArrSubSub' } }, + }, + }, + ], }; PropertyFactory.register(ConstantPolyMapContainer); @@ -2714,12 +2713,12 @@ describe('PropertyFactory', function () { expect(instance.get('map').getEntriesReadOnly().key3.get('num2').getValue()).to.equal(111); }); - it('should fail when setting constant polymorphic values not derived from base type', function () { + it('should fail when setting constant polymorphic values not derived from base type', function() { var ConstantPoly = { typeid: 'SimpleTest:ConstantPoly-1.0.0', constants: [ - { id: 'num', typeid: 'Uint32', value: 111 } - ] + { id: 'num', typeid: 'Uint32', value: 111 }, + ], }; var ConstantPolyUnderivedContainer = { @@ -2727,9 +2726,9 @@ describe('PropertyFactory', function () { constants: [ { id: 'poly', typeid: 'SimpleTest:ConstantPolyBase-1.0.0', - typedValue: { typeid: 'SimpleTest:ConstantPoly-1.0.0', value: { num: 333 } } - } - ] + typedValue: { typeid: 'SimpleTest:ConstantPoly-1.0.0', value: { num: 333 } }, + }, + ], }; PropertyFactory.register(ConstantPoly); @@ -2739,12 +2738,12 @@ describe('PropertyFactory', function () { .to.throw(MSG.TYPED_VALUES_MUST_DERIVE_FROM_BASE_TYPE + 'SimpleTest:ConstantPoly-1.0.0'); }); - it('should fail when setting a typedValue to a primitive.', function () { + it('should fail when setting a typedValue to a primitive.', function() { var DefaultPrimitiveArrayPoly = { typeid: 'SimpleTest:DefaultPrimitivePoly-1.0.0', constants: [{ - id: 'int', typeid: 'Int32', typedValue: { typeid: 'Int32', value: 123 } - }] + id: 'int', typeid: 'Int32', typedValue: { typeid: 'Int32', value: 123 }, + }], }; PropertyFactory.register(DefaultPrimitiveArrayPoly); @@ -2753,12 +2752,12 @@ describe('PropertyFactory', function () { .to.throw(MSG.TYPED_VALUES_FOR_PRIMITIVES_NOT_SUPPORTED + 'int'); }); - it('should fail when setting a typedValue to a primitive array.', function () { + it('should fail when setting a typedValue to a primitive array.', function() { var DefaultPrimitiveArrayPoly = { typeid: 'SimpleTest:DefaultPrimitiveArrayPoly-1.0.0', constants: [{ - id: 'array', context: 'array', typeid: 'Int32', typedValue: [{ typeid: 'Int32', value: 123 }] - }] + id: 'array', context: 'array', typeid: 'Int32', typedValue: [{ typeid: 'Int32', value: 123 }], + }], }; PropertyFactory.register(DefaultPrimitiveArrayPoly); @@ -2767,15 +2766,15 @@ describe('PropertyFactory', function () { .to.throw(MSG.TYPED_VALUES_FOR_PRIMITIVES_NOT_SUPPORTED + 'array'); }); - it('should fail when setting a typedValue to a primitive map.', function () { + it('should fail when setting a typedValue to a primitive map.', function() { var DefaultPrimitiveMapPoly = { typeid: 'SimpleTest:DefaultPrimitiveMapPoly-1.0.0', constants: [{ id: 'map', context: 'map', typeid: 'Int32', typedValue: { key1: { typeid: 'Int32', value: 1 }, - key2: { typeid: 'Int32', value: 2 } - } - }] + key2: { typeid: 'Int32', value: 2 }, + }, + }], }; PropertyFactory.register(DefaultPrimitiveMapPoly); @@ -2786,8 +2785,8 @@ describe('PropertyFactory', function () { }); }); - describe('InstanceOf Type Checking', function () { - it('Native types pass instanceOf check', function () { + describe('InstanceOf Type Checking', function() { + it('Native types pass instanceOf check', function() { var contextSingleTypes = ['NodeProperty', 'Enum']; var propTypes = ['String', 'Bool', 'Int8', 'Uint8', 'Int16', 'Uint16', 'Int32', 'Int64', 'Uint64', 'Uint32', 'Float32', 'Float64', 'Reference']; @@ -2810,61 +2809,60 @@ describe('PropertyFactory', function () { } }); - it('instanceOf check succeeds for schema based properties and native typeids', function () { + it('instanceOf check succeeds for schema based properties and native typeids', function() { PropertyFactory.register(SimplePoint); expect(PropertyFactory.instanceOf(PropertyFactory.create(SimplePoint.typeid), 'BaseProperty')).to.be.true; const testEnum = { inherits: 'Enum', typeid: 'test:testEnum-1.0.0', - properties: [{ id: 'test', value: 1 }] + properties: [{ id: 'test', value: 1 }], }; PropertyFactory.register(testEnum); expect(PropertyFactory.instanceOf( PropertyFactory.create(testEnum.typeid, 'array'), 'Enum', 'array')).to.be.true; }); - it('instanceOf check fails for non native typeids', function () { + it('instanceOf check fails for non native typeids', function() { PropertyFactory.register(SimplePoint); expect(PropertyFactory.instanceOf(PropertyFactory.create(SimplePoint.typeid), SimplePoint.typeid)).to.be.false; }); }); }); -describe('Template registration', function () { +describe('Template registration', function() { var ColorID, myPropertyFactory; - before(function () { + before(function() { ColorID = require('./validation/goodColorId'); }); - beforeEach(function () { + beforeEach(function() { this.sinon = sinon.createSandbox(); this.sinon.stub(console, 'warn'); myPropertyFactory = new PropertyFactory.constructor(); }); - afterEach(function () { + afterEach(function() { this.sinon.restore(); }); - it('should register a versioned template', function () { + it('should register a versioned template', function() { myPropertyFactory.register(ColorID['1-0-0'].original); }); it( 'should print a warning when registering an existing template that is not different from what is in the registry', - function () { + function() { myPropertyFactory.register(ColorID['1-0-0'].original); myPropertyFactory.register(ColorID['1-0-0'].original); expect(console.warn.callCount).to.equal(1); - } + }, ); it( 'should accept registering a different template from what is in the registry if it is semantically equivalent', - function () { - + function() { var testPropertyTypeId = 'TEST:array.Float32-0.0.1'; var ValuesTemplate1 = { typeid: testPropertyTypeId, @@ -2872,8 +2870,8 @@ describe('Template registration', function () { properties: [{ id: 'values', context: 'array', - typeid: 'Float32' - }] + typeid: 'Float32', + }], }; var ValuesTemplate2 = { @@ -2883,50 +2881,49 @@ describe('Template registration', function () { id: 'values', context: 'array', typeid: 'Float32', - length: 0 - }] + length: 0, + }], }; myPropertyFactory.register(ValuesTemplate1); expect(myPropertyFactory.register.bind(myPropertyFactory, ValuesTemplate2)).to.not.throw(); - - } + }, ); it( 'should throw when registering an existing template version that is different from what is in the registry', - function () { + function() { myPropertyFactory.register(ColorID['1-0-0'].original); expect(myPropertyFactory.register.bind( myPropertyFactory, - ColorID['1-0-0'].modified) + ColorID['1-0-0'].modified), ).to.throw(Error); - } + }, ); - it('should throw when registering an unversioned template', function () { + it('should throw when registering an unversioned template', function() { expect(myPropertyFactory.register.bind( myPropertyFactory, - require('./validation/badMissingSemverInTypeid') + require('./validation/badMissingSemverInTypeid'), )).to.throw(Error); }); - it('should throw when registering an invalid versioned template', function () { + it('should throw when registering an invalid versioned template', function() { expect(myPropertyFactory.register.bind( myPropertyFactory, - require('./validation/badPrimitiveTypeid') + require('./validation/badPrimitiveTypeid'), )).to.throw(Error); }); - it('should throw when registering a primitive property through the public API', function () { + it('should throw when registering a primitive property through the public API', function() { expect(myPropertyFactory.register.bind( myPropertyFactory, 'String', - StringProperty) + StringProperty), ).to.throw(Error); }); - it('should register templates out of order without any warnings or errors', function () { + it('should register templates out of order without any warnings or errors', function() { myPropertyFactory.register(ColorID['1-0-0'].original); myPropertyFactory.register(ColorID['1-1-0'].goodSemver); myPropertyFactory.register(ColorID['1-0-1'].goodSemver); @@ -2940,19 +2937,19 @@ describe('Template registration', function () { expect(console.warn.callCount).to.equal(0); }); - it('should register a new template with the PATCH version updated', function () { + it('should register a new template with the PATCH version updated', function() { myPropertyFactory.register(ColorID['1-0-0'].original); myPropertyFactory.register(ColorID['1-0-1'].goodSemver); expect(console.warn.callCount).to.equal(0); }); - it('should register a new template with the MINOR version updated', function () { + it('should register a new template with the MINOR version updated', function() { myPropertyFactory.register(ColorID['1-0-0'].original); myPropertyFactory.register(ColorID['1-1-0'].goodSemver); expect(console.warn.callCount).to.equal(0); }); - it('should print a warning when registering a new template with the wrong version updated', function () { + it('should print a warning when registering a new template with the wrong version updated', function() { myPropertyFactory.register(ColorID['1-0-0'].original); myPropertyFactory.register(ColorID['1-1-0'].badSemver1); @@ -2971,20 +2968,20 @@ describe('Template registration', function () { expect(console.warn.callCount).to.equal(4); }); - it('should register a new template with the MAJOR version updated', function () { + it('should register a new template with the MAJOR version updated', function() { myPropertyFactory.register(ColorID['1-0-0'].original); myPropertyFactory.register(ColorID['2-0-0']); expect(console.warn.callCount).to.equal(0); }); - it('should register a versioned remote template', function () { + it('should register a versioned remote template', function() { myPropertyFactory._registerRemoteTemplate(ColorID['1-0-0'].original, generateGUID()); }); it( 'should pass when registering a versioned remote template that exists' + ' in the local registry but is the same from what is locally registered', - function () { + function() { myPropertyFactory.register(ColorID['1-0-0'].original); myPropertyFactory._registerRemoteTemplate(ColorID['1-0-0'].original, generateGUID()); @@ -2993,33 +2990,33 @@ describe('Template registration', function () { myPropertyFactory._registerRemoteTemplate(ColorID['1-0-0'].original, generateGUID()); myPropertyFactory.register(ColorID['1-0-0'].original); expect(console.warn.callCount).to.equal(0); - } + }, ); it( 'should fail when registering a versioned remote template that exists' + ' in the local registry but differs from what is locally registered', - function () { + function() { myPropertyFactory.register(ColorID['1-0-0'].original); expect(myPropertyFactory._registerRemoteTemplate.bind( myPropertyFactory, ColorID['1-0-0'].modified, - generateGUID()) + generateGUID()), ).to.throw(Error); - } + }, ); - it('should throw when registering an unversioned remote template', function () { + it('should throw when registering an unversioned remote template', function() { expect(myPropertyFactory._registerRemoteTemplate.bind( myPropertyFactory, require('./validation/badMissingSemverInTypeid'), - generateGUID() + generateGUID(), )).to.throw(Error); }); it( 'should register a remote template even when there are other versions of the same template in the local registry', - function () { + function() { var scope = generateGUID(); myPropertyFactory.register(ColorID['1-0-0'].original); myPropertyFactory.register(ColorID['2-0-0']); @@ -3027,12 +3024,12 @@ describe('Template registration', function () { myPropertyFactory._registerRemoteTemplate(ColorID['1-1-0'].goodSemver, scope); myPropertyFactory._registerRemoteTemplate(ColorID['1-0-1'].goodSemver, scope); expect(console.warn.callCount).to.equal(0); - } + }, ); it( 'should register a local template even when there are other versions of the same template in the remote registry', - function () { + function() { var scope = generateGUID(); var scope2 = generateGUID(); myPropertyFactory._registerRemoteTemplate(ColorID['1-1-0'].goodSemver, scope); @@ -3044,12 +3041,12 @@ describe('Template registration', function () { myPropertyFactory.register(ColorID['2-0-0']); expect(console.warn.callCount).to.equal(0); - } + }, ); - it('`registered` event is triggered when registering a template', function (done) { + it('`registered` event is triggered when registering a template', function(done) { var typeid = 'test:schemaReg-1.0.0'; - var registeredEventListener = function (template) { + var registeredEventListener = function(template) { expect(template).to.exist; expect(template.typeid).to.equal(typeid); done(); @@ -3058,14 +3055,14 @@ describe('Template registration', function () { PropertyFactory.addListener('registered', registeredEventListener); PropertyFactory.register({ - typeid: typeid + typeid: typeid, }); // We remove the listener to avoid unnecessary calls for later templates registration. PropertyFactory.removeListener('registered', registeredEventListener); }); }); -describe('Only properties and constants that inherit from NamedProperty can have the "set" context', function () { +describe('Only properties and constants that inherit from NamedProperty can have the "set" context', function() { beforeEach(() => PropertyFactory._clear()); afterEach(() => PropertyFactory._clear()); @@ -3073,7 +3070,7 @@ describe('Only properties and constants that inherit from NamedProperty can have describe('should throw when trying to register a set not inheriting from a namedProperty', () => { it('declared in a template', () => { var templateChild = { - typeid: 'adsk.test:anotherTestSchema-1.0.0' + typeid: 'adsk.test:anotherTestSchema-1.0.0', }; var template = { @@ -3082,9 +3079,9 @@ describe('Only properties and constants that inherit from NamedProperty can have { id: 'something', context: 'set', - typeid: 'adsk.test:anotherTestSchema-1.0.0' - } - ] + typeid: 'adsk.test:anotherTestSchema-1.0.0', + }, + ], }; PropertyFactory.register(template); @@ -3097,12 +3094,12 @@ describe('Only properties and constants that inherit from NamedProperty can have it('declared in a template with two level of inheritance', () => { var itemParentTemplate = { - typeid: 'adsk.test:itemParent-1.0.0' + typeid: 'adsk.test:itemParent-1.0.0', }; var itemTemplate = { typeid: 'adsk.test:item-1.0.0', - inherits: 'adsk.test:itemParent-1.0.0' + inherits: 'adsk.test:itemParent-1.0.0', }; var template = { @@ -3111,9 +3108,9 @@ describe('Only properties and constants that inherit from NamedProperty can have { id: 'something', context: 'set', - typeid: 'adsk.test:item-1.0.0' - } - ] + typeid: 'adsk.test:item-1.0.0', + }, + ], }; PropertyFactory.register(itemParentTemplate); @@ -3127,7 +3124,7 @@ describe('Only properties and constants that inherit from NamedProperty can have it('when passed as a parameter of the create method', () => { var template = { - typeid: 'adsk.test:test-1.0.0' + typeid: 'adsk.test:test-1.0.0', }; PropertyFactory.register(template); @@ -3143,7 +3140,7 @@ describe('Only properties and constants that inherit from NamedProperty can have describe('should throw when trying to register a set not inheriting from a namedProperty', () => { it('declared in a template', () => { var templateChild = { - typeid: 'adsk.test:anotherTestSchema-1.0.0' + typeid: 'adsk.test:anotherTestSchema-1.0.0', }; var template = { @@ -3153,9 +3150,9 @@ describe('Only properties and constants that inherit from NamedProperty can have id: 'something', context: 'set', typeid: 'adsk.test:anotherTestSchema-1.0.0', - value: 'hello' - } - ] + value: 'hello', + }, + ], }; PropertyFactory.register(template); @@ -3168,12 +3165,12 @@ describe('Only properties and constants that inherit from NamedProperty can have it('declared in a template with two level of inheritance', () => { var itemParentTemplate = { - typeid: 'adsk.test:itemParent-1.0.0' + typeid: 'adsk.test:itemParent-1.0.0', }; var itemTemplate = { typeid: 'adsk.test:item-1.0.0', - inherits: 'adsk.test:itemParent-1.0.0' + inherits: 'adsk.test:itemParent-1.0.0', }; var template = { @@ -3183,9 +3180,9 @@ describe('Only properties and constants that inherit from NamedProperty can have id: 'something', context: 'set', typeid: 'adsk.test:item-1.0.0', - value: 'hello' - } - ] + value: 'hello', + }, + ], }; PropertyFactory.register(itemParentTemplate); @@ -3199,15 +3196,15 @@ describe('Only properties and constants that inherit from NamedProperty can have var unit = { 'annotation': { 'description': 'A definite magnitude used as a standard of measurement.', - 'doc': 'http://docs.adskunits.apiary.io/#introduction/definitions/measurement-units' + 'doc': 'http://docs.adskunits.apiary.io/#introduction/definitions/measurement-units', }, 'typeid': 'autodesk.unit:unit-1.0.0', 'constants': [ { 'id': 'name', - 'typeid': 'String' - } - ] + 'typeid': 'String', + }, + ], }; var quantity = { 'annotation': { 'description': 'A quantity typically measured in a particular set of compatible units.' }, @@ -3215,16 +3212,16 @@ describe('Only properties and constants that inherit from NamedProperty can have 'constants': [ { 'id': 'name', - 'typeid': 'String' + 'typeid': 'String', }, { 'id': 'units', 'typeid': 'autodesk.unit:unit-1.0.0', 'context': 'array', 'typedValue': [], - 'annotation': { 'description': 'List of all measurement units applicable to the measurable quantity.' } - } - ] + 'annotation': { 'description': 'List of all measurement units applicable to the measurable quantity.' }, + }, + ], }; var area = { 'annotation': { 'description': 'Area.' }, @@ -3235,18 +3232,18 @@ describe('Only properties and constants that inherit from NamedProperty can have { 'id': 'units', 'typedValue': [ - { 'typeid': 'autodesk.unit.unit:squareCentimeters-1.0.0' } - ] - } - ] + { 'typeid': 'autodesk.unit.unit:squareCentimeters-1.0.0' }, + ], + }, + ], }; var centimeter = { 'annotation': { 'description': 'Square centimeters.' }, 'typeid': 'autodesk.unit.unit:squareCentimeters-1.0.0', 'inherits': ['autodesk.unit:unit-1.0.0'], 'constants': [ - { 'id': 'name', 'value': 'Square centimeters' } - ] + { 'id': 'name', 'value': 'Square centimeters' }, + ], }; it('@bugfix should support constant which inhirets from a polymorphic array', () => { PropertyFactory.register(unit); @@ -3263,11 +3260,11 @@ describe('Only properties and constants that inherit from NamedProperty can have }); }); -describe('Async validation', function () { +describe('Async validation', function() { var TemplateValidator; - var inheritsFromAsync = function (child, ancestor) { - return new Promise(function (resolve, reject) { - setTimeout(function () { + var inheritsFromAsync = async function(child, ancestor) { + return new Promise(function(resolve, reject) { + setTimeout(function() { try { resolve(PropertyFactory.inheritsFrom(child, ancestor)); } catch (error) { @@ -3277,48 +3274,48 @@ describe('Async validation', function () { }); }; - var hasSchemaAsync = function (typeid) { - return new Promise(function (resolve, reject) { - setTimeout(function () { + var hasSchemaAsync = async function(typeid) { + return new Promise(function(resolve, reject) { + setTimeout(function() { resolve(PropertyFactory._has(typeid)); }, 0); }); }; - before(function () { + before(function() { TemplateValidator = require('@fluid-experimental/property-changeset').TemplateValidator; }); - it('can validate asynchronously', function () { + it('can validate asynchronously', function() { var templateValidator = new TemplateValidator({ inheritsFromAsync: inheritsFromAsync, - hasSchemaAsync: hasSchemaAsync + hasSchemaAsync: hasSchemaAsync, }); var templatePrevious = JSON.parse(JSON.stringify(require('./validation/goodPointId'))); var template = JSON.parse(JSON.stringify(templatePrevious)); template.typeid = 'TeamLeoValidation2:PointID-0.9.9'; - return templateValidator.validateAsync(template, templatePrevious).then(function (result) { + return templateValidator.validateAsync(template, templatePrevious).then(function(result) { expect(result).property('isValid', false); expect(result.errors.length).to.be.at.least(1); expect(result.errors[0].message).to.have.string(MSG.VERSION_REGRESSION_1); }); }); - it('can perform context validation asynchronously', function (done) { + it('can perform context validation asynchronously', function(done) { var templateValidator = new TemplateValidator({ inheritsFromAsync: inheritsFromAsync, - hasSchemaAsync: hasSchemaAsync + hasSchemaAsync: hasSchemaAsync, }); // Doesn't inherit from 'NamedProperty'. Will cause an error var grandParentSchema = { - 'typeid': 'test:grandparentschema-1.0.0' + 'typeid': 'test:grandparentschema-1.0.0', }; var parentSchema = { 'typeid': 'test:parentschema-1.0.0', - 'inherits': ['test:grandparentschema-1.0.0'] + 'inherits': ['test:grandparentschema-1.0.0'], }; var childSchema = { @@ -3327,17 +3324,17 @@ describe('Async validation', function () { { id: 'set', typeid: 'test:parentschema-1.0.0', - context: 'set' - } - ] + context: 'set', + }, + ], }; PropertyFactory.register(grandParentSchema); PropertyFactory.register(parentSchema); - templateValidator.validateAsync(childSchema).then(function (result) { + templateValidator.validateAsync(childSchema).then(function(result) { done(new Error('Should not be valid!')); - }).catch(function (error) { + }).catch(function(error) { expect(error).to.exist; done(); }); @@ -3350,8 +3347,8 @@ describe('inheritsFrom() method', () => { PropertyFactory.register([ { typeid: 'autodesk.examples:test.set-1.0.0', - inherits: 'NamedProperty' - } + inherits: 'NamedProperty', + }, ]); }); @@ -3457,14 +3454,12 @@ describe('inheritsFrom() method', () => { expect(result).to.be.true; }); - it('should recognize that the NamedNodeProperty inherits from BaseProperty', () => { const result = PropertyFactory.inheritsFrom('NamedNodeProperty', 'BaseProperty'); expect(result).to.be.true; }); - it('should recognize that the NodeProperty inherits from ContainerProperty', () => { const result = PropertyFactory.inheritsFrom('NodeProperty', 'ContainerProperty'); @@ -3538,7 +3533,7 @@ describe('inheritsFrom() method', () => { it('should return true if in_templateTypeid = in_baseTypeid', () => { const result = PropertyFactory.inheritsFrom( 'autodesk.examples:test.set-1.0.0', - 'autodesk.examples:test.set-1.0.0' + 'autodesk.examples:test.set-1.0.0', ); expect(result).to.be.true; @@ -3548,7 +3543,7 @@ describe('inheritsFrom() method', () => { const result = PropertyFactory.inheritsFrom( 'autodesk.examples:test.set-1.0.0', 'autodesk.examples:test.set-1.0.0', - { includeSelf: false } + { includeSelf: false }, ); expect(result).to.be.false; @@ -3559,7 +3554,7 @@ describe('inheritsFrom() method', () => { // add a second schema for the cache tests PropertyFactory.register({ typeid: 'autodesk.examples:test.set-2.0.0', - inherits: 'NamedProperty' + inherits: 'NamedProperty', }); }); @@ -3571,13 +3566,13 @@ describe('inheritsFrom() method', () => { 'autodesk.examples:test.set-1.0.0': { BaseProperty: true, AbstractStaticCollectionProperty: true, - NamedProperty: true + NamedProperty: true, }, 'autodesk.examples:test.set-2.0.0': { BaseProperty: true, AbstractStaticCollectionProperty: true, - NamedProperty: true - } + NamedProperty: true, + }, }; expect(PropertyFactory._inheritanceCache).to.deep.equal(expectedResults); @@ -3596,13 +3591,13 @@ describe('inheritsFrom() method', () => { 'autodesk.examples:test.set-1.0.0': { BaseProperty: true, AbstractStaticCollectionProperty: true, - NodeProperty: true + NodeProperty: true, }, 'autodesk.examples:test.set-2.0.0': { BaseProperty: true, AbstractStaticCollectionProperty: true, - NodeProperty: true - } + NodeProperty: true, + }, }; expect(PropertyFactory._inheritanceCache).to.deep.equal(expectedResults); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/propertyTemplateWrapper.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/propertyTemplateWrapper.spec.js index 8e00d905feac..f966cfcac683 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/propertyTemplateWrapper.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/propertyTemplateWrapper.spec.js @@ -11,14 +11,14 @@ */ const { PropertyFactory } = require('..'); -describe('Property Template Wrapper', function () { - describe('Compiled Template Creation', function () { - it('should work for template that has no inheritence', function () { +describe('Property Template Wrapper', function() { + describe('Compiled Template Creation', function() { + it('should work for template that has no inheritence', function() { var noParents = { typeid: 'SimpleTest:NoParents-1.0.0', properties: [ - { id: 'area', typeid: 'Float32' } - ] + { id: 'area', typeid: 'Float32' }, + ], }; PropertyFactory.register(noParents); @@ -29,30 +29,30 @@ describe('Property Template Wrapper', function () { expect(compiledTemplate).to.deep.equal(wrapper.getPropertyTemplate()); }); - it('should contain properties from parent templates', function () { + it('should contain properties from parent templates', function() { var withParents = { typeid: 'SimpleTest:WithParents-1.0.0', inherits: [ 'SimpleTest:Parent1-1.0.0', - 'SimpleTest:Parent2-1.0.0' + 'SimpleTest:Parent2-1.0.0', ], properties: [ - { id: 'area', typeid: 'Float32' } - ] + { id: 'area', typeid: 'Float32' }, + ], }; var parent1 = { typeid: 'SimpleTest:Parent1-1.0.0', properties: [ - { id: 'parent1Prop', typeid: 'Float32' } - ] + { id: 'parent1Prop', typeid: 'Float32' }, + ], }; var parent2 = { typeid: 'SimpleTest:Parent2-1.0.0', properties: [ - { id: 'parent2Prop', typeid: 'Float32' } - ] + { id: 'parent2Prop', typeid: 'Float32' }, + ], }; PropertyFactory._reregister(parent1); @@ -65,34 +65,34 @@ describe('Property Template Wrapper', function () { expect(compiledTemplate.properties).to.deep.equal([ { id: 'area', typeid: 'Float32' }, { id: 'parent1Prop', typeid: 'Float32' }, - { id: 'parent2Prop', typeid: 'Float32' } + { id: 'parent2Prop', typeid: 'Float32' }, ]); }); - it('should contain constants from parent templates', function () { + it('should contain constants from parent templates', function() { var withParents = { typeid: 'SimpleTest:WithParents-1.0.0', inherits: [ 'SimpleTest:Parent1-1.0.0', - 'SimpleTest:Parent2-1.0.0' + 'SimpleTest:Parent2-1.0.0', ], constants: [ - { id: 'area', typeid: 'Float32' } - ] + { id: 'area', typeid: 'Float32' }, + ], }; var parent1 = { typeid: 'SimpleTest:Parent1-1.0.0', constants: [ - { id: 'parent1Prop', typeid: 'Float32' } - ] + { id: 'parent1Prop', typeid: 'Float32' }, + ], }; var parent2 = { typeid: 'SimpleTest:Parent2-1.0.0', constants: [ - { id: 'parent2Prop', typeid: 'Float32' } - ] + { id: 'parent2Prop', typeid: 'Float32' }, + ], }; PropertyFactory._reregister(parent1); @@ -105,26 +105,26 @@ describe('Property Template Wrapper', function () { expect(compiledTemplate.constants).to.deep.equal([ { id: 'area', typeid: 'Float32' }, { id: 'parent1Prop', typeid: 'Float32' }, - { id: 'parent2Prop', typeid: 'Float32' } + { id: 'parent2Prop', typeid: 'Float32' }, ]); }); - it('should merge property if found in both child and parent', function () { + it('should merge property if found in both child and parent', function() { var withParents = { typeid: 'SimpleTest:WithParents-1.0.0', inherits: [ - 'SimpleTest:Parent1-1.0.0' + 'SimpleTest:Parent1-1.0.0', ], properties: [ - { id: 'area', value: '1.1' } - ] + { id: 'area', value: '1.1' }, + ], }; var parent1 = { typeid: 'SimpleTest:Parent1-1.0.0', properties: [ - { id: 'area', context: 'array', typeid: 'Float32' } - ] + { id: 'area', context: 'array', typeid: 'Float32' }, + ], }; PropertyFactory._reregister(parent1); @@ -134,26 +134,26 @@ describe('Property Template Wrapper', function () { var compiledTemplate = wrapper.getCompiledTemplate(PropertyFactory); expect(compiledTemplate.properties).to.deep.equal([ - { id: 'area', context: 'array', typeid: 'Float32', value: '1.1' } + { id: 'area', context: 'array', typeid: 'Float32', value: '1.1' }, ]); }); - it('should merge constant if found in both child and parent', function () { + it('should merge constant if found in both child and parent', function() { var withParents = { typeid: 'SimpleTest:WithParents-1.0.0', inherits: [ - 'SimpleTest:Parent1-1.0.0' + 'SimpleTest:Parent1-1.0.0', ], constants: [ - { id: 'area', value: '1.1' } - ] + { id: 'area', value: '1.1' }, + ], }; var parent1 = { typeid: 'SimpleTest:Parent1-1.0.0', constants: [ - { id: 'area', context: 'array', typeid: 'Float32' } - ] + { id: 'area', context: 'array', typeid: 'Float32' }, + ], }; PropertyFactory._reregister(parent1); @@ -163,11 +163,11 @@ describe('Property Template Wrapper', function () { var compiledTemplate = wrapper.getCompiledTemplate(PropertyFactory); expect(compiledTemplate.constants).to.deep.equal([ - { id: 'area', context: 'array', typeid: 'Float32', value: '1.1' } + { id: 'area', context: 'array', typeid: 'Float32', value: '1.1' }, ]); }); - it('should throw error if schema inherits from more than one creation type', function () { + it('should throw error if schema inherits from more than one creation type', function() { var badTemplate = { typeid: 'SimpleTest:BadTemplate-1.0.0', inherits: ['NodeProperty', 'Binary'], @@ -176,23 +176,23 @@ describe('Property Template Wrapper', function () { id: 'props', properties: [ { id: 'area', properties: [ - { id: 'length', typeid: 'Float32' }] - }] - }] + { id: 'length', typeid: 'Float32' }], + }], + }], }; - expect(() => { PropertyFactory.register(badTemplate) }).to.throw(); + expect(() => { PropertyFactory.register(badTemplate); }).to.throw(); }); - it('should throw error if schema indirectly inherits from more than one creation type', function () { + it('should throw error if schema indirectly inherits from more than one creation type', function() { var badParent1 = { typeid: 'SimpleTest:BadParent1-1.0.0', - inherits: ['NodeProperty'] + inherits: ['NodeProperty'], }; var badParent2 = { typeid: 'SimpleTest:BadParent2-1.0.0', - inherits: ['Binary'] + inherits: ['Binary'], }; var badTemplate = { @@ -203,9 +203,9 @@ describe('Property Template Wrapper', function () { id: 'props', properties: [ { id: 'area', properties: [ - { id: 'length', typeid: 'Float32' }] - }] - }] + { id: 'length', typeid: 'Float32' }], + }], + }], }; expect(() => { diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/propertyUtils.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/propertyUtils.spec.js index 9d723faf8daf..f12caeb47901 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/propertyUtils.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/propertyUtils.spec.js @@ -4,7 +4,7 @@ */ /* globals assert */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /* eslint-disable max-nested-callbacks */ /* eslint-disable max-len */ @@ -17,10 +17,9 @@ const _ = require('lodash'); const { PropertyFactory } = require('..'); const { PropertyUtils } = require('..'); -describe('PropertyUtils', function () { - - describe('PropertyUtils.gatherProperties', function () { - it('should return a list of properties that match the predicate', function () { +describe('PropertyUtils', function() { + describe('PropertyUtils.gatherProperties', function() { + it('should return a list of properties that match the predicate', function() { var testTemplate = { typeid: 'autodesk.test:testProp-1.0.0', properties: [ @@ -29,10 +28,10 @@ describe('PropertyUtils', function () { { id: 'nested', properties: [ { id: 'c', typeid: 'Float64' }, - { id: 'd', typeid: 'String' } - ] - } - ] + { id: 'd', typeid: 'String' }, + ], + }, + ], }; PropertyFactory.register(testTemplate); var myProperty = PropertyFactory.create('autodesk.test:testProp-1.0.0'); @@ -41,7 +40,7 @@ describe('PropertyUtils', function () { myProperty.get('nested').get('c').setValue(42); myProperty.get('nested').get('d').setValue('Hello again!'); - var result = PropertyUtils.gatherProperties(myProperty, function (property) { + var result = PropertyUtils.gatherProperties(myProperty, function(property) { return _.isNumber(property.value); }); expect(result['a']).to.exist; @@ -50,5 +49,4 @@ describe('PropertyUtils', function () { expect(result['nested.d']).to.not.exist; }); }); - }); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/reversibleChangeset.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/reversibleChangeset.spec.js index ecfd5a143487..3a42057f6ebd 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/reversibleChangeset.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/reversibleChangeset.spec.js @@ -2,21 +2,19 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -/* globals expect*/ +/* globals expect */ /** * @fileoverview In this file, we will test the functions of the property factory. */ const _ = require('lodash'); -const { PropertyFactory } = require('..'); -const { ChangeSet } = require('@fluid-experimental/property-changeset') +const { ChangeSet } = require('@fluid-experimental/property-changeset'); const { Int64, Uint64 } = require('@fluid-experimental/property-common'); +const { PropertyFactory } = require('..'); const deepCopy = _.cloneDeep; -describe('Reversible ChangeSets', function () { - - var testRevAndInvCS = function (initialProperty, modificationFunction, +describe('Reversible ChangeSets', function() { + var testRevAndInvCS = function(initialProperty, modificationFunction, expectedRevCS, expectedAfterCS, expectedInverseCS) { - var initialChangeSet = new ChangeSet(initialProperty._serialize(false)); initialChangeSet.setIsNormalized(true); var initialChangeSetBackup = deepCopy(initialChangeSet.getSerializedChangeSet()); @@ -40,7 +38,6 @@ describe('Reversible ChangeSets', function () { cs2Strip._stripReversibleChangeSet(); expect(cs2.getSerializedChangeSet()).to.deep.equal(cs2Strip.getSerializedChangeSet()); - cs2._toReversibleChangeSet(initialChangeSet.getSerializedChangeSet()); var csR = cs2.clone(); csR._toReversibleChangeSet(initialChangeSet.getSerializedChangeSet()); @@ -74,33 +71,32 @@ describe('Reversible ChangeSets', function () { expect(initialPropertyClone._serialize(false)).to.deep.equal(initialPropertyBackup._serialize(false)); }; - before(function () { - + before(function() { var TaskSubjectParentTemplate = { typeid: 'autodesk.tests:ChangeSetApplyAfterTask.parentTemplate-1.0.0', properties: [ { id: 'directMember', typeid: 'autodesk.tests:ChangeSetApplyAfterTask.memberTemplate-1.0.0' }, { id: 'nested', properties: [ - { id: 'member', typeid: 'autodesk.tests:ChangeSetApplyAfterTask.nestedTemplate-1.0.0' } - ] - } - ] + { id: 'member', typeid: 'autodesk.tests:ChangeSetApplyAfterTask.nestedTemplate-1.0.0' }, + ], + }, + ], }; var TaskSubjectMemberTemplate = { typeid: 'autodesk.tests:ChangeSetApplyAfterTask.memberTemplate-1.0.0', properties: [ { id: 'progress', typeid: 'Uint32' }, - { id: 'timeRemaining', typeid: 'Uint32' } - ] + { id: 'timeRemaining', typeid: 'Uint32' }, + ], }; var TaskSubjectTestTemplate = { typeid: 'autodesk.tests:ChangeSetApplyAfterTask.nodeTemplate-1.0.0', properties: [ { id: 'result', typeid: 'NodeProperty' }, - { id: 'integer', typeid: 'Uint32' } - ] + { id: 'integer', typeid: 'Uint32' }, + ], }; // Register the templates from the discussion document @@ -109,8 +105,8 @@ describe('Reversible ChangeSets', function () { properties: [ { id: 'x', typeid: 'Float32' }, { id: 'y', typeid: 'Float32' }, - { id: 'z', typeid: 'Float32' } - ] + { id: 'z', typeid: 'Float32' }, + ], }; var Point2DTemplate = { @@ -119,41 +115,41 @@ describe('Reversible ChangeSets', function () { { id: 'position', properties: [ { id: 'x', typeid: 'Float32' }, - { id: 'y', typeid: 'Float32' } - ] + { id: 'y', typeid: 'Float32' }, + ], }, { id: 'normal', typeid: 'autodesk.test:vector3-1.0.0' }, { id: 'neighbours', typeid: 'autodesk.test:vector3-1.0.0', context: 'map' }, - { id: 'temperature', typeid: 'Float32' } - ] + { id: 'temperature', typeid: 'Float32' }, + ], }; var TestArrayFloat32 = { typeid: 'autodesk.test:test.arrayfloat32-1.0.0', properties: [ - { id: 'data', typeid: 'Float32', context: 'array' } - ] + { id: 'data', typeid: 'Float32', context: 'array' }, + ], }; var SimpleStringTestPropertyTemplate = { typeid: 'autodesk.tests:DataStringTestProperty-1.0.0', properties: [ - { id: 'data', typeid: 'String' } - ] + { id: 'data', typeid: 'String' }, + ], }; var SimpleRefTestPropertyTemplate = { typeid: 'autodesk.tests:DataRefTestProperty-1.0.0', properties: [ - { id: 'data', typeid: 'Reference' } - ] + { id: 'data', typeid: 'Reference' }, + ], }; var SimpleMapTestPropertyTemplate = { typeid: 'autodesk.tests:MapTestPropertyID-1.0.0', properties: [ - { id: 'data', typeid: 'Float32', context: 'map' } - ] + { id: 'data', typeid: 'Float32', context: 'map' }, + ], }; var TestPropertyTemplate = { @@ -162,21 +158,21 @@ describe('Reversible ChangeSets', function () { properties: [ { id: 'stringProperty', typeid: 'String' }, { id: 'stringProperty2', typeid: 'String' }, - { id: 'map', context: 'map', typeid: 'NamedProperty' } - ] + { id: 'map', context: 'map', typeid: 'NamedProperty' }, + ], }; var AnonymousTestPropertyTemplate = { typeid: 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0', properties: [ - { id: 'stringProperty', typeid: 'String' } - ] + { id: 'stringProperty', typeid: 'String' }, + ], }; var CuststomArrayTemplate = { typeid: 'autodesk.tests:CustomArrayChangesetTestID-1.0.0', properties: [ - { id: 'data', typeid: 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0', context: 'array' } - ] + { id: 'data', typeid: 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0', context: 'array' }, + ], }; var TestEnumTemplate = { @@ -186,21 +182,21 @@ describe('Reversible ChangeSets', function () { properties: [ { id: 'm', value: 1, annotation: { description: 'meter' } }, { id: 'cm', value: 2, annotation: { description: 'centimeter' } }, - { id: 'mm', value: 3, annotation: { description: 'millimeter' } } - ] + { id: 'mm', value: 3, annotation: { description: 'millimeter' } }, + ], }; PropertyFactory._reregister(TestEnumTemplate); var TestBaseContainingEnumTemplate = { typeid: 'autodesk.core:CustomWithEnumID-1.0.0', properties: [{ - id: 'data', typeid: 'autodesk.core:UnitsEnum-1.0.0' - }] + id: 'data', typeid: 'autodesk.core:UnitsEnum-1.0.0', + }], }; var TestInheritsNodePropertyObject = { inherits: ['NodeProperty'], - typeid: 'autodesk.tests:SimpleInheritsNodeProperty-1.0.0' + typeid: 'autodesk.tests:SimpleInheritsNodeProperty-1.0.0', }; PropertyFactory._reregister(TestInheritsNodePropertyObject); @@ -222,282 +218,278 @@ describe('Reversible ChangeSets', function () { PropertyFactory._reregister(TestArrayFloat32); }); - describe('Make inversible, apply and reverse for primitive properties.', function () { - - it('should work for modifying Int8', function () { + describe('Make inversible, apply and reverse for primitive properties.', function() { + it('should work for modifying Int8', function() { var prop = PropertyFactory.create('Int8'); testRevAndInvCS( prop, - function () { prop.setValue(10); }, + function() { prop.setValue(10); }, { 'oldValue': 0, 'value': 10 }, 10, { 'oldValue': 10, 'value': 0 }); }); - it('should work for modifying Uint8', function () { + it('should work for modifying Uint8', function() { var prop = PropertyFactory.create('Uint8'); testRevAndInvCS( prop, - function () { prop.setValue(10); }, + function() { prop.setValue(10); }, { 'oldValue': 0, 'value': 10 }, 10, { 'oldValue': 10, 'value': 0 }); }); - it('should work for modifying Int16', function () { + it('should work for modifying Int16', function() { var prop = PropertyFactory.create('Int16'); testRevAndInvCS( prop, - function () { prop.setValue(10); }, + function() { prop.setValue(10); }, { 'oldValue': 0, 'value': 10 }, 10, { 'oldValue': 10, 'value': 0 }); }); - it('should work for modifying Uint16', function () { + it('should work for modifying Uint16', function() { var prop = PropertyFactory.create('Uint16'); testRevAndInvCS( prop, - function () { prop.setValue(10); }, + function() { prop.setValue(10); }, { 'oldValue': 0, 'value': 10 }, 10, { 'oldValue': 10, 'value': 0 }); }); - it('should work for modifying Int32', function () { + it('should work for modifying Int32', function() { var prop = PropertyFactory.create('Int32'); testRevAndInvCS( prop, - function () { prop.setValue(10); }, + function() { prop.setValue(10); }, { 'oldValue': 0, 'value': 10 }, 10, { 'oldValue': 10, 'value': 0 }); }); - it('should work for modifying Uint32', function () { + it('should work for modifying Uint32', function() { var prop = PropertyFactory.create('Uint32'); testRevAndInvCS( prop, - function () { prop.setValue(10); }, + function() { prop.setValue(10); }, { 'oldValue': 0, 'value': 10 }, 10, { 'oldValue': 10, 'value': 0 }); }); - it('should work for modifying Int64', function () { + it('should work for modifying Int64', function() { var prop = PropertyFactory.create('Int64'); testRevAndInvCS( prop, - function () { prop.setValue(new Int64(10, 10)); }, + function() { prop.setValue(new Int64(10, 10)); }, { 'oldValue': [0, 0], 'value': [10, 10] }, [10, 10], { 'oldValue': [10, 10], 'value': [0, 0] }); }); - it('should work for modifying Uint64', function () { + it('should work for modifying Uint64', function() { var prop = PropertyFactory.create('Uint64'); testRevAndInvCS( prop, - function () { prop.setValue(new Uint64(10, 10)); }, + function() { prop.setValue(new Uint64(10, 10)); }, { 'oldValue': [0, 0], 'value': [10, 10] }, [10, 10], { 'oldValue': [10, 10], 'value': [0, 0] }); }); - it('should work for modifying Float32', function () { + it('should work for modifying Float32', function() { var prop = PropertyFactory.create('Float32'); testRevAndInvCS( prop, - function () { prop.setValue(0.5); }, + function() { prop.setValue(0.5); }, { 'oldValue': 0, 'value': 0.5 }, 0.5, { 'oldValue': 0.5, 'value': 0 }); }); - it('should work for modifying Float64', function () { + it('should work for modifying Float64', function() { var prop = PropertyFactory.create('Float64'); testRevAndInvCS( prop, - function () { prop.setValue(0.5); }, + function() { prop.setValue(0.5); }, { 'oldValue': 0, 'value': 0.5 }, 0.5, { 'oldValue': 0.5, 'value': 0 }); }); - it('should work for modifying Bool', function () { + it('should work for modifying Bool', function() { var prop = PropertyFactory.create('Bool'); testRevAndInvCS( prop, - function () { prop.setValue(true); }, + function() { prop.setValue(true); }, { 'oldValue': false, 'value': true }, true, { 'oldValue': true, 'value': false }); }); // These tests have been disabled, since the interface of // the ChangeSet class is ambiguous when inserting a string - it.skip('@bugfix should work for modifying String', function () { + it.skip('@bugfix should work for modifying String', function() { var prop = PropertyFactory.create('String'); testRevAndInvCS( prop, - function () { prop.setValue('test'); }, + function() { prop.setValue('test'); }, { 'oldValue': '', 'value': 'test' }, 'test', { 'oldValue': 'test', 'value': '' }); }); // These tests have been disabled, since the interface of // the ChangeSet class is ambiguous when inserting a string - it.skip('@bugfix should work for modifying Reference', function () { + it.skip('@bugfix should work for modifying Reference', function() { var prop = PropertyFactory.create('Reference'); testRevAndInvCS( prop, - function () { prop.setValue('/'); }, + function() { prop.setValue('/'); }, { 'oldValue': '', 'value': '/' }, '/', { 'oldValue': '/', 'value': '' }); }); }); - describe('Make inversible, apply and reverse for primitive properties in a NodeProperty.', function () { - - it('should work for modifying Int8', function () { + describe('Make inversible, apply and reverse for primitive properties in a NodeProperty.', function() { + it('should work for modifying Int8', function() { var node = PropertyFactory.create('NodeProperty'); var prop = PropertyFactory.create('Int8'); node.insert('prop', prop); testRevAndInvCS( node, - function () { prop.setValue(10); }, + function() { prop.setValue(10); }, { 'modify': { 'Int8': { 'prop': { 'oldValue': 0, 'value': 10 } } } }, { 'insert': { 'Int8': { 'prop': 10 } } }, { 'modify': { 'Int8': { 'prop': { 'oldValue': 10, 'value': 0 } } } }); }); - it('should work for modifying Uint8', function () { + it('should work for modifying Uint8', function() { var node = PropertyFactory.create('NodeProperty'); var prop = PropertyFactory.create('Uint8'); node.insert('prop', prop); testRevAndInvCS( node, - function () { prop.setValue(10); }, + function() { prop.setValue(10); }, { 'modify': { 'Uint8': { 'prop': { 'oldValue': 0, 'value': 10 } } } }, { 'insert': { 'Uint8': { 'prop': 10 } } }, { 'modify': { 'Uint8': { 'prop': { 'oldValue': 10, 'value': 0 } } } }); }); - it('should work for modifying Int16', function () { + it('should work for modifying Int16', function() { var node = PropertyFactory.create('NodeProperty'); var prop = PropertyFactory.create('Int16'); node.insert('prop', prop); testRevAndInvCS( node, - function () { prop.setValue(10); }, + function() { prop.setValue(10); }, { 'modify': { 'Int16': { 'prop': { 'oldValue': 0, 'value': 10 } } } }, { 'insert': { 'Int16': { 'prop': 10 } } }, { 'modify': { 'Int16': { 'prop': { 'oldValue': 10, 'value': 0 } } } }); }); - it('should work for modifying Uint16', function () { + it('should work for modifying Uint16', function() { var node = PropertyFactory.create('NodeProperty'); var prop = PropertyFactory.create('Uint16'); node.insert('prop', prop); testRevAndInvCS( node, - function () { prop.setValue(10); }, + function() { prop.setValue(10); }, { 'modify': { 'Uint16': { 'prop': { 'oldValue': 0, 'value': 10 } } } }, { 'insert': { 'Uint16': { 'prop': 10 } } }, { 'modify': { 'Uint16': { 'prop': { 'oldValue': 10, 'value': 0 } } } }); }); - it('should work for modifying Int32', function () { + it('should work for modifying Int32', function() { var node = PropertyFactory.create('NodeProperty'); var prop = PropertyFactory.create('Int32'); node.insert('prop', prop); testRevAndInvCS( node, - function () { prop.setValue(10); }, + function() { prop.setValue(10); }, { 'modify': { 'Int32': { 'prop': { 'oldValue': 0, 'value': 10 } } } }, { 'insert': { 'Int32': { 'prop': 10 } } }, { 'modify': { 'Int32': { 'prop': { 'oldValue': 10, 'value': 0 } } } }); }); - it('should work for modifying Uint32', function () { + it('should work for modifying Uint32', function() { var node = PropertyFactory.create('NodeProperty'); var prop = PropertyFactory.create('Uint32'); node.insert('prop', prop); testRevAndInvCS( node, - function () { prop.setValue(10); }, + function() { prop.setValue(10); }, { 'modify': { 'Uint32': { 'prop': { 'oldValue': 0, 'value': 10 } } } }, { 'insert': { 'Uint32': { 'prop': 10 } } }, { 'modify': { 'Uint32': { 'prop': { 'oldValue': 10, 'value': 0 } } } }); }); - it('should work for modifying Int64', function () { + it('should work for modifying Int64', function() { var node = PropertyFactory.create('NodeProperty'); var prop = PropertyFactory.create('Int64'); node.insert('prop', prop); testRevAndInvCS( node, - function () { prop.setValue(new Int64(10, 10)); }, + function() { prop.setValue(new Int64(10, 10)); }, { 'modify': { 'Int64': { 'prop': { 'oldValue': [0, 0], 'value': [10, 10] } } } }, { 'insert': { 'Int64': { 'prop': [10, 10] } } }, { 'modify': { 'Int64': { 'prop': { 'oldValue': [10, 10], 'value': [0, 0] } } } }); }); - it('should work for modifying Uint64', function () { + it('should work for modifying Uint64', function() { var node = PropertyFactory.create('NodeProperty'); var prop = PropertyFactory.create('Uint64'); node.insert('prop', prop); testRevAndInvCS( node, - function () { prop.setValue(new Uint64(10, 10)); }, + function() { prop.setValue(new Uint64(10, 10)); }, { 'modify': { 'Uint64': { 'prop': { 'oldValue': [0, 0], 'value': [10, 10] } } } }, { 'insert': { 'Uint64': { 'prop': [10, 10] } } }, { 'modify': { 'Uint64': { 'prop': { 'oldValue': [10, 10], 'value': [0, 0] } } } }); }); - it('should work for modifying Float32', function () { + it('should work for modifying Float32', function() { var node = PropertyFactory.create('NodeProperty'); var prop = PropertyFactory.create('Float32'); node.insert('prop', prop); testRevAndInvCS( node, - function () { prop.setValue(0.5); }, + function() { prop.setValue(0.5); }, { 'modify': { 'Float32': { 'prop': { 'oldValue': 0, 'value': 0.5 } } } }, { 'insert': { 'Float32': { 'prop': 0.5 } } }, { 'modify': { 'Float32': { 'prop': { 'oldValue': 0.5, 'value': 0 } } } }); }); - it('should work for modifying Float64', function () { + it('should work for modifying Float64', function() { var node = PropertyFactory.create('NodeProperty'); var prop = PropertyFactory.create('Float64'); node.insert('prop', prop); testRevAndInvCS( node, - function () { prop.setValue(0.5); }, + function() { prop.setValue(0.5); }, { 'modify': { 'Float64': { 'prop': { 'oldValue': 0, 'value': 0.5 } } } }, { 'insert': { 'Float64': { 'prop': 0.5 } } }, { 'modify': { 'Float64': { 'prop': { 'oldValue': 0.5, 'value': 0 } } } }); }); - it('should work for modifying Bool', function () { + it('should work for modifying Bool', function() { var node = PropertyFactory.create('NodeProperty'); var prop = PropertyFactory.create('Bool'); node.insert('prop', prop); testRevAndInvCS( node, - function () { prop.setValue(true); }, + function() { prop.setValue(true); }, { 'modify': { 'Bool': { 'prop': { 'oldValue': false, 'value': true } } } }, { 'insert': { 'Bool': { 'prop': true } } }, { 'modify': { 'Bool': { 'prop': { 'oldValue': true, 'value': false } } } }); }); - it('should work for modifying String', function () { + it('should work for modifying String', function() { var node = PropertyFactory.create('NodeProperty'); var prop = PropertyFactory.create('String'); node.insert('prop', prop); testRevAndInvCS( node, - function () { prop.setValue('test'); }, + function() { prop.setValue('test'); }, { 'modify': { 'String': { 'prop': { 'oldValue': '', 'value': 'test' } } } }, { 'insert': { 'String': { 'prop': 'test' } } }, { 'modify': { 'String': { 'prop': { 'oldValue': 'test', 'value': '' } } } }); }); - it('should work for modifying Reference', function () { + it('should work for modifying Reference', function() { var node = PropertyFactory.create('NodeProperty'); var prop = PropertyFactory.create('Reference'); node.insert('prop', prop); testRevAndInvCS( node, - function () { prop.setValue('/'); }, + function() { prop.setValue('/'); }, { 'modify': { 'Reference': { 'prop': { 'oldValue': '', 'value': '/' } } } }, { 'insert': { 'Reference': { 'prop': '/' } } }, { 'modify': { 'Reference': { 'prop': { 'oldValue': '/', 'value': '' } } } }); }); }); - describe('apply reversible ChangeSets on all properties', function () { - - - it('should work for primitive properties', function () { + describe('apply reversible ChangeSets on all properties', function() { + it('should work for primitive properties', function() { var prop = PropertyFactory.create('autodesk.test:vector3-1.0.0'); var propCopy = PropertyFactory.create('autodesk.test:vector3-1.0.0'); prop._properties.x.value = 2; @@ -508,8 +500,7 @@ describe('Reversible ChangeSets', function () { expect(prop._serialize(true)).to.deep.equal(propCopy._serialize(true)); }); - - it('should work for string properties', function () { + it('should work for string properties', function() { var prop = PropertyFactory.create('autodesk.tests:DataStringTestProperty-1.0.0'); var propCopy = PropertyFactory.create('autodesk.tests:DataStringTestProperty-1.0.0'); prop._properties.data.value = 'A'; @@ -520,7 +511,7 @@ describe('Reversible ChangeSets', function () { expect(prop._serialize(true)).to.deep.equal(propCopy._serialize(true)); }); - it('should work for reference properties', function () { + it('should work for reference properties', function() { var root = PropertyFactory.create('NodeProperty'); var prop = PropertyFactory.create('autodesk.tests:DataRefTestProperty-1.0.0'); var propCopy = PropertyFactory.create('autodesk.tests:DataRefTestProperty-1.0.0'); @@ -536,7 +527,7 @@ describe('Reversible ChangeSets', function () { expect(prop._serialize(true)).to.deep.equal(propCopy._serialize(true)); }); - it('should work for enum properties', function () { + it('should work for enum properties', function() { var prop = PropertyFactory.create('autodesk.core:CustomWithEnumID-1.0.0'); var propCopy = PropertyFactory.create('autodesk.core:CustomWithEnumID-1.0.0'); prop._properties.data.value = 'cm'; @@ -547,8 +538,7 @@ describe('Reversible ChangeSets', function () { expect(prop._serialize(true)).to.deep.equal(propCopy._serialize(true)); }); - it('should work for indexed collections of complex types', function () { - + it('should work for indexed collections of complex types', function() { var prop = PropertyFactory.create('autodesk.tests:MapTestNamedPropertyID-1.0.0'); var propCopy = PropertyFactory.create('autodesk.tests:MapTestNamedPropertyID-1.0.0'); @@ -573,8 +563,7 @@ describe('Reversible ChangeSets', function () { expect(prop._serialize(true)).to.deep.equal(propCopy._serialize(true)); }); - it('should work for indexed collections of primitive types', function () { - + it('should work for indexed collections of primitive types', function() { var prop = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var propCopy = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); @@ -596,8 +585,7 @@ describe('Reversible ChangeSets', function () { expect(prop._serialize(true)).to.deep.equal(propCopy._serialize(true)); }); - - it('should work for custom array properties', function () { + it('should work for custom array properties', function() { var prop = PropertyFactory.create('autodesk.tests:CustomArrayChangesetTestID-1.0.0'); var propCopy = PropertyFactory.create('autodesk.tests:CustomArrayChangesetTestID-1.0.0'); @@ -621,7 +609,7 @@ describe('Reversible ChangeSets', function () { expect(prop.serialize({ 'dirtyOnly': true })).to.deep.equal(propCopy.serialize({ 'dirtyOnly': true })); }); - it('should work for primitive array properties', function () { + it('should work for primitive array properties', function() { var prop = PropertyFactory.create('autodesk.test:test.arrayfloat32-1.0.0'); var propCopy = PropertyFactory.create('autodesk.test:test.arrayfloat32-1.0.0'); prop._properties.data.insertRange(0, [10, 11, 12, 13, 14, 15, 16]); @@ -640,7 +628,7 @@ describe('Reversible ChangeSets', function () { expect(prop.serialize({ 'dirtyOnly': true })).to.deep.equal(propCopy.serialize({ 'dirtyOnly': true })); }); - it('should work for node properties', function () { + it('should work for node properties', function() { var prop = PropertyFactory.create('NodeProperty'); var propCopy = PropertyFactory.create('NodeProperty'); @@ -671,7 +659,7 @@ describe('Reversible ChangeSets', function () { expect(prop.serialize({ 'dirtyOnly': true })).to.deep.equal(propCopy.serialize({ 'dirtyOnly': true })); }); - it('should work for inherits node properties', function () { + it('should work for inherits node properties', function() { var root = PropertyFactory.create('NodeProperty'); var prop = PropertyFactory.create('autodesk.tests:SimpleInheritsNodeProperty-1.0.0'); root.insert('prop', prop); @@ -708,10 +696,10 @@ describe('Reversible ChangeSets', function () { }); }); - describe('Apply with reversible ChangeSets', function () { - var overlapApplyTest = function (in_type, in_inputArrayOperations1, in_inputArrayOperations2, + describe('Apply with reversible ChangeSets', function() { + var overlapApplyTest = function(in_type, in_inputArrayOperations1, in_inputArrayOperations2, in_outputArrayOperations) { - var convertModificationSetToArray = function (in_modificationSet) { + var convertModificationSetToArray = function(in_modificationSet) { return in_modificationSet.map((x) => { return x[2] === undefined ? [x[0], x[1].split('')] : @@ -719,7 +707,7 @@ describe('Reversible ChangeSets', function () { }); }; - var performApplyTest = function (in_typeid, inputArrayOperations1, inputArrayOperations2, outputArrayOperations) { + var performApplyTest = function(in_typeid, inputArrayOperations1, inputArrayOperations2, outputArrayOperations) { var CS1 = new ChangeSet({ 'modify': { [in_typeid]: { 'arr': { [in_type]: inputArrayOperations1 } } } }); var CS2 = { 'modify': { [in_typeid]: { 'arr': { [in_type]: inputArrayOperations2 } } } }; var CS2_copy = deepCopy(CS2); @@ -730,18 +718,18 @@ describe('Reversible ChangeSets', function () { // CS2 should no longer contain the removal of A expect(CS1.getSerializedChangeSet()).to.deep.equal({ - 'modify': { [in_typeid]: { 'arr': { [in_type]: outputArrayOperations } } } + 'modify': { [in_typeid]: { 'arr': { [in_type]: outputArrayOperations } } }, }); }; - it('on strings', function () { + it('on strings', function() { performApplyTest('String', deepCopy(in_inputArrayOperations1), in_inputArrayOperations2, in_outputArrayOperations); }); - it('on arrays', function () { + it('on arrays', function() { performApplyTest('array', convertModificationSetToArray(in_inputArrayOperations1), convertModificationSetToArray(in_inputArrayOperations2), @@ -749,14 +737,14 @@ describe('Reversible ChangeSets', function () { }); }; - describe('for overlapping modifies 1', function () { + describe('for overlapping modifies 1', function() { overlapApplyTest('modify', [[3, 'abc', '123']], [[3, 'def', 'abc']], [[3, 'def', '123']]); }); - describe('for overlapping modifies 2', function () { + describe('for overlapping modifies 2', function() { overlapApplyTest('modify', [[0, 'abc', '123']], [[2, 'def', 'c45']], @@ -764,10 +752,10 @@ describe('Reversible ChangeSets', function () { }); }); - describe('Rebase with reversible ChangeSets', function () { - var overlapRebaseTest = function (in_type, in_inputArrayOperations1, in_inputArrayOperations2, + describe('Rebase with reversible ChangeSets', function() { + var overlapRebaseTest = function(in_type, in_inputArrayOperations1, in_inputArrayOperations2, in_outputArrayOperations, in_expectedConflicts) { - var convertModificationSetToArray = function (in_modificationSet) { + var convertModificationSetToArray = function(in_modificationSet) { return in_modificationSet.map((x) => { return x[2] === undefined ? [x[0], x[1].split('')] : @@ -775,7 +763,7 @@ describe('Reversible ChangeSets', function () { }); }; - var performRebaseTest = function (in_typeid, inputArrayOperations1, inputArrayOperations2, outputArrayOperations) { + var performRebaseTest = function(in_typeid, inputArrayOperations1, inputArrayOperations2, outputArrayOperations) { var conflicts = []; var CS1_initial = { 'modify': { [in_typeid]: { 'arr': { [in_type]: inputArrayOperations1 } } } }; var CS1 = new ChangeSet(deepCopy(CS1_initial)); @@ -792,14 +780,14 @@ describe('Reversible ChangeSets', function () { expect(CS2).to.deep.equal({ 'modify': { [in_typeid]: { 'arr': { [in_type]: outputArrayOperations } } } }); }; - it('on strings', function () { + it('on strings', function() { performRebaseTest('String', in_inputArrayOperations1, in_inputArrayOperations2, in_outputArrayOperations); }); - it('on arrays', function () { + it('on arrays', function() { performRebaseTest('array', convertModificationSetToArray(in_inputArrayOperations1), convertModificationSetToArray(in_inputArrayOperations2), @@ -807,7 +795,7 @@ describe('Reversible ChangeSets', function () { }); }; - describe('for overlapping removes', function () { + describe('for overlapping removes', function() { overlapRebaseTest('remove', [[0, '']], [[1, 'ABC']], @@ -815,7 +803,7 @@ describe('Reversible ChangeSets', function () { 0); }); - describe('for overlapping removes 2', function () { + describe('for overlapping removes 2', function() { overlapRebaseTest('remove', [[2, 'C>']], [[0, 'ABC']], @@ -823,7 +811,7 @@ describe('Reversible ChangeSets', function () { 0); }); - describe('for overlapping removes 3', function () { + describe('for overlapping removes 3', function() { overlapRebaseTest('remove', [[2, 'CD>']], [[0, 'ABC'], [4, '>']], @@ -831,7 +819,7 @@ describe('Reversible ChangeSets', function () { 0); }); - describe('for overlapping modifies', function () { + describe('for overlapping modifies', function() { overlapRebaseTest('modify', [[0, '', '.']], [[1, '123', '---']], @@ -839,7 +827,7 @@ describe('Reversible ChangeSets', function () { 1); }); - describe('for overlapping modifies 2', function () { + describe('for overlapping modifies 2', function() { overlapRebaseTest('modify', [[2, 'C>', '..']], [[0, '123', '---']], @@ -847,7 +835,7 @@ describe('Reversible ChangeSets', function () { 1); }); - describe('for overlapping modifies 3', function () { + describe('for overlapping modifies 3', function() { overlapRebaseTest('modify', [[2, 'CD>', '..']], [[0, '123', '---'], [4, '45', '--']], @@ -855,15 +843,15 @@ describe('Reversible ChangeSets', function () { 2); }); - it('for array modify rebases', function () { + it('for array modify rebases', function() { var CS = new ChangeSet({ 'array': { 'elements': { 'modify': [ - [1, [1, 2, 3], [0, 1, 2]] - ] - } - } + [1, [1, 2, 3], [0, 1, 2]], + ], + }, + }, }); var rebasedCS = CS._rebaseChangeSet({ @@ -873,37 +861,37 @@ describe('Reversible ChangeSets', function () { [ 0, [0, 1, 2, 3], - [1, 2, 3, 4] - ] - ] - } - } + [1, 2, 3, 4], + ], + ], + }, + }, }, []); expect(rebasedCS['array'].elements.modify[0].length).to.equal(3); }); }); - describe('applying reversible CS to primitive string types', function () { - it('should work for strings', function () { + describe('applying reversible CS to primitive string types', function() { + it('should work for strings', function() { var CS = new ChangeSet({ 'String': { 'test': { 'value': '10', 'oldValue': '9' } } }); CS.applyChangeSet({ 'String': { 'test': { 'value': '8', 'oldValue': '10' } } }); expect(CS.getSerializedChangeSet()).to.deep.equal({ 'String': { 'test': { 'value': '8', 'oldValue': '9' } } }); }); - it('should work for strings', function () { + it('should work for strings', function() { var CS = new ChangeSet({ 'Float64': { 'test': { 'value': 10, 'oldValue': 9 } } }); CS.applyChangeSet({ 'Float64': { 'test': { 'value': 8, 'oldValue': 10 } } }); expect(CS.getSerializedChangeSet()).to.deep.equal({ 'Float64': { 'test': { 'value': 8, 'oldValue': 9 } } }); }); - it('should work for bool', function () { + it('should work for bool', function() { // TODO: This should become a NOP var CS = new ChangeSet({ 'Bool': { 'test': { 'value': false, 'oldValue': true } } }); CS.applyChangeSet({ 'Bool': { 'test': { 'value': true, 'oldValue': false } } }); expect(CS.getSerializedChangeSet()).to.deep.equal({ 'Bool': { 'test': { 'value': true, 'oldValue': true } } }); }); - it('should work for bool', function () { + it('should work for bool', function() { // TODO: This should become a NOP var CS = new ChangeSet({}); CS.applyChangeSet({ 'Bool': { 'test': { 'value': true, 'oldValue': false } } }); @@ -911,27 +899,27 @@ describe('Reversible ChangeSets', function () { }); }); - describe('_stripReversibleChangeSet should', function () { - it('correctly handle removes at the root', function () { + describe('_stripReversibleChangeSet should', function() { + it('correctly handle removes at the root', function() { var CS = new ChangeSet({ remove: { String: { - testString: 'abcde' - } - } + testString: 'abcde', + }, + }, }); CS._stripReversibleChangeSet(); expect(CS.getSerializedChangeSet()).to.deep.equal({ - remove: ['testString'] + remove: ['testString'], }); }); - it('ignore the root when passing it a flag', function () { + it('ignore the root when passing it a flag', function() { var SCS = { remove: { String: { - testString: 'abcde' - } - } + testString: 'abcde', + }, + }, }; var CS = new ChangeSet(SCS); CS._stripReversibleChangeSet(true); @@ -939,54 +927,54 @@ describe('Reversible ChangeSets', function () { }); }); - describe('should return a minimal CS when squashing', function () { - it('matching primitive type remove/insert combinations in a polymorphic indexed collection', function () { + describe('should return a minimal CS when squashing', function() { + it('matching primitive type remove/insert combinations in a polymorphic indexed collection', function() { // These two operations should cancel out var CS1 = new ChangeSet({ remove: { String: { A: 'A' } } }); var CS2 = new ChangeSet({ insert: { String: { A: 'A' } } }); CS1.applyChangeSet(CS2); expect(CS1.getSerializedChangeSet()).to.deep.equal({}); }); - it('non matching primitive type remove/insert combinations in a polymorphic indexed collection', function () { + it('non matching primitive type remove/insert combinations in a polymorphic indexed collection', function() { // These two operations should result in a modify var CS1 = new ChangeSet({ remove: { String: { A: 'A' } } }); var CS2 = new ChangeSet({ insert: { String: { A: 'B' } } }); CS1.applyChangeSet(CS2); expect(CS1.getSerializedChangeSet()).to.deep.equal({ modify: { String: { A: 'B' } } }); }); - it('matching remove/insert combinations in a primitive type indexed collection', function () { + it('matching remove/insert combinations in a primitive type indexed collection', function() { // These two operations should cancel out var CS1 = new ChangeSet({ modify: { 'map': { test: { remove: { A: 'A' } } } } }); var CS2 = new ChangeSet({ modify: { 'map': { test: { insert: { A: 'A' } } } } }); CS1.applyChangeSet(CS2); expect(CS1.getSerializedChangeSet()).to.deep.equal({}); }); - it('non matching primitive type remove/insert combinations in a polymorphic indexed collection', function () { + it('non matching primitive type remove/insert combinations in a polymorphic indexed collection', function() { // These two operations should result in a modify var CS1 = new ChangeSet({ modify: { 'map': { test: { remove: { A: 'A' } } } } }); var CS2 = new ChangeSet({ modify: { 'map': { test: { insert: { A: 'B' } } } } }); CS1.applyChangeSet(CS2); expect(CS1.getSerializedChangeSet()).to.deep.equal({ modify: { 'map': { test: { modify: { A: 'B' } } } } }); }); - it('matching complex type remove/insert combinations in a polymorphic indexed collection', function () { + it('matching complex type remove/insert combinations in a polymorphic indexed collection', function() { // These two operations should cancel out var CS1 = new ChangeSet({ remove: { 'RepositoryTest:Nametag-1.0.0': { name: 'A' } } }); var CS2 = new ChangeSet({ insert: { 'RepositoryTest:Nametag-1.0.0': { name: 'A' } } }); CS1.applyChangeSet(CS2); expect(CS1.getSerializedChangeSet()).to.deep.equal({}); }); - it('non matching complex type remove/insert combinations in a polymorphic indexed collection', function () { + it('non matching complex type remove/insert combinations in a polymorphic indexed collection', function() { // TODO: How should we treat these operations? Should they be rewritten to a modify? var CS1 = new ChangeSet({ remove: { 'RepositoryTest:Nametag-1.0.0': { name: 'A' } } }); var CS2 = new ChangeSet({ insert: { 'RepositoryTest:Nametag-1.0.0': { name: 'B' } } }); CS1.applyChangeSet(CS2); expect(CS1.getSerializedChangeSet()).to.deep.equal({ remove: { 'RepositoryTest:Nametag-1.0.0': { name: 'A' } }, - insert: { 'RepositoryTest:Nametag-1.0.0': { name: 'B' } } + insert: { 'RepositoryTest:Nametag-1.0.0': { name: 'B' } }, }); }); - it('matching primitive type remove/insert operations in primitive type arrays', function () { + it('matching primitive type remove/insert operations in primitive type arrays', function() { // These two operations should cancel out var CS1 = new ChangeSet({ modify: { 'array': { test: { remove: [[0, ['A', 'B', 'C']]] } } } }); var CS2 = new ChangeSet({ modify: { 'array': { test: { insert: [[0, ['A', 'B', 'C']]] } } } }); @@ -995,12 +983,12 @@ describe('Reversible ChangeSets', function () { }); }); - it('should work for primitive array properties', function () { + it('should work for primitive array properties', function() { var prop = PropertyFactory.create('autodesk.test:test.arrayfloat32-1.0.0'); prop._properties.data.insertRange(0, [10, 11, 12, 13, 14, 15, 16]); testRevAndInvCS( prop, - function (in_prop) { + function(in_prop) { in_prop._properties.data.setRange(1, [21, 22]); in_prop._properties.data.removeRange(4, 3); in_prop._properties.data.insert(0, 9); @@ -1010,76 +998,76 @@ describe('Reversible ChangeSets', function () { 'data': { 'modify': [[1, [21, 22], [11, 12]]], 'remove': [[4, [14, 15, 16]]], - 'insert': [[0, [9]]] - } - } + 'insert': [[0, [9]]], + }, + }, }, { 'array': { 'data': { - 'insert': [[0, [9, 10, 21, 22, 13]]] - } - } + 'insert': [[0, [9, 10, 21, 22, 13]]], + }, + }, }, { 'array': { 'data': { 'modify': [[2, [11, 12], [21, 22]]], 'insert': [[5, [14, 15, 16]]], - 'remove': [[0, [9]]] - } - } - } + 'remove': [[0, [9]]], + }, + }, + }, ); }); - it('should work for insertions into empty primitive array properties', function () { + it('should work for insertions into empty primitive array properties', function() { var prop = PropertyFactory.create('autodesk.test:test.arrayfloat32-1.0.0'); testRevAndInvCS( prop, - function (in_prop) { + function(in_prop) { in_prop._properties.data.insertRange(0, [1, 2, 3]); }, { 'array': { 'data': { - 'insert': [[0, [1, 2, 3]]] - } - } + 'insert': [[0, [1, 2, 3]]], + }, + }, }, { 'array': { 'data': { - 'insert': [[0, [1, 2, 3]]] - } - } + 'insert': [[0, [1, 2, 3]]], + }, + }, }, { 'array': { 'data': { - 'remove': [[0, [1, 2, 3]]] - } - } - } + 'remove': [[0, [1, 2, 3]]], + }, + }, + }, ); }); - it('should not crash with an empty input if it is not needed in the actual CS', function () { + it('should not crash with an empty input if it is not needed in the actual CS', function() { var initialCS = { 'NodeProperty': { insert: { NodeProperty: { - test2: {} - } - } - } + test2: {}, + }, + }, + }, }; var CS = new ChangeSet(deepCopy(initialCS)); CS._toReversibleChangeSet({}); expect(CS.getSerializedChangeSet()).to.deep.equal(initialCS); }); - it('should work for inserts, even if the corresponding property is missing in the initial state', function () { + it('should work for inserts, even if the corresponding property is missing in the initial state', function() { // This test checks, whether changesets with insert work, even if the corresponding property is not present in the // initial changeset. Since the initial changeset is not needed for the insert, we don't need to throw an // error in that case. This type of situation can occur in the materialized history, if an insert happens right @@ -1089,31 +1077,31 @@ describe('Reversible ChangeSets', function () { 'test': { insert: { NodeProperty: { - test2: {} - } - } - } - } + test2: {}, + }, + }, + }, + }, }; var CS = new ChangeSet(deepCopy(initialCS)); CS._toReversibleChangeSet({}); expect(CS.getSerializedChangeSet()).to.deep.equal(initialCS); }); - it('should work for simple primitive properties', function () { + it('should work for simple primitive properties', function() { var cs = new ChangeSet({ insert: { 'Float32': { - 'myFloat': 23 - } - } + 'myFloat': 23, + }, + }, }); var cs2 = new ChangeSet({ modify: { 'Float32': { - 'myFloat': 42 - } - } + 'myFloat': 42, + }, + }, }); var cs2Rev = cs2.clone(); @@ -1145,11 +1133,11 @@ describe('Reversible ChangeSets', function () { expect(cs.getSerializedChangeSet()).to.deep.equal({ 'insert': { 'Float32': { 'myFloat': 23 } } }); }); - it('should work for templated properties', function () { + it('should work for templated properties', function() { var prop = PropertyFactory.create('autodesk.test:point2d-1.0.0'); testRevAndInvCS( prop, - function (in_prop) { + function(in_prop) { in_prop._properties.position.x.value = 2; in_prop._properties.normal.y.value = 4; in_prop._properties.temperature.value = 21; @@ -1157,66 +1145,66 @@ describe('Reversible ChangeSets', function () { { 'Float32': { 'position.x': { 'value': 2, 'oldValue': 0 }, - 'temperature': { 'value': 21, 'oldValue': 0 } + 'temperature': { 'value': 21, 'oldValue': 0 }, }, 'autodesk.test:vector3-1.0.0': { - 'normal': { 'Float32': { 'y': { 'value': 4, 'oldValue': 0 } } } - } + 'normal': { 'Float32': { 'y': { 'value': 4, 'oldValue': 0 } } }, + }, }, { 'Float32': { - 'position.x': 2, 'position.y': 0, 'temperature': 21 + 'position.x': 2, 'position.y': 0, 'temperature': 21, }, 'autodesk.test:vector3-1.0.0': { - 'normal': { 'Float32': { 'x': 0, 'y': 4, 'z': 0 } } + 'normal': { 'Float32': { 'x': 0, 'y': 4, 'z': 0 } }, }, - 'map': { 'neighbours': {} } + 'map': { 'neighbours': {} }, }, { 'Float32': { 'position.x': { 'value': 0, 'oldValue': 2 }, - 'temperature': { 'value': 0, 'oldValue': 21 } + 'temperature': { 'value': 0, 'oldValue': 21 }, }, 'autodesk.test:vector3-1.0.0': { - 'normal': { 'Float32': { 'y': { 'value': 0, 'oldValue': 4 } } } - } - } + 'normal': { 'Float32': { 'y': { 'value': 0, 'oldValue': 4 } } }, + }, + }, ); }); - it('should work for string properties initialized by set', function () { + it('should work for string properties initialized by set', function() { var prop = PropertyFactory.create('autodesk.tests:DataStringTestProperty-1.0.0'); prop._properties.data.value = 'Hello world'; testRevAndInvCS( prop, - function (in_prop) { + function(in_prop) { in_prop._properties.data.setRange(1, 'aih'); in_prop._properties.data.removeRange(6, 5); in_prop._properties.data.insertRange(0, 'Hi, '); }, { 'String': { 'data': { 'modify': [[1, 'aih', 'ell']], 'remove': [[6, 'world']], 'insert': [[0, 'Hi, ']] } } }, { 'String': { 'data': 'Hi, Haiho ' } }, - { 'String': { 'data': { 'modify': [[5, 'ell', 'aih']], 'remove': [[0, 'Hi, ']], 'insert': [[10, 'world']] } } } + { 'String': { 'data': { 'modify': [[5, 'ell', 'aih']], 'remove': [[0, 'Hi, ']], 'insert': [[10, 'world']] } } }, ); }); - it('should work for string properties initialized by insert', function () { + it('should work for string properties initialized by insert', function() { var prop = PropertyFactory.create('autodesk.tests:DataStringTestProperty-1.0.0'); prop._properties.data.insert(0, 'Hello world'); testRevAndInvCS( prop, - function (in_prop) { + function(in_prop) { in_prop._properties.data.setRange(1, 'aih'); in_prop._properties.data.removeRange(6, 5); in_prop._properties.data.insertRange(0, 'Hi, '); }, { 'String': { 'data': { 'modify': [[1, 'aih', 'ell']], 'remove': [[6, 'world']], 'insert': [[0, 'Hi, ']] } } }, { 'String': { 'data': 'Hi, Haiho ' } }, - { 'String': { 'data': { 'modify': [[5, 'ell', 'aih']], 'remove': [[0, 'Hi, ']], 'insert': [[10, 'world']] } } } + { 'String': { 'data': { 'modify': [[5, 'ell', 'aih']], 'remove': [[0, 'Hi, ']], 'insert': [[10, 'world']] } } }, ); }); - it('should work for primitive map properties', function () { + it('should work for primitive map properties', function() { var property = PropertyFactory.create('autodesk.tests:MapTestPropertyID-1.0.0'); var prop = property._properties.data; prop.insert('A', 3); @@ -1225,7 +1213,7 @@ describe('Reversible ChangeSets', function () { prop.insert('D', 6); testRevAndInvCS( property, - function (myProp) { + function(myProp) { myProp._properties.data.set('A', 7); myProp._properties.data.remove('B'); myProp._properties.data.remove('C'); @@ -1237,30 +1225,30 @@ describe('Reversible ChangeSets', function () { 'data': { 'remove': { 'B': 4, 'C': 5 }, 'modify': { 'A': { 'value': 7, 'oldValue': 3 }, 'D': { 'value': 8, 'oldValue': 6 } }, - 'insert': { 'F': 9 } - } - } + 'insert': { 'F': 9 }, + }, + }, }, { 'map': { 'data': { - 'insert': { 'A': 7, 'D': 8, 'F': 9 } - } - } + 'insert': { 'A': 7, 'D': 8, 'F': 9 }, + }, + }, }, { 'map': { 'data': { 'modify': { 'A': { 'value': 3, 'oldValue': 7 }, 'D': { 'value': 6, 'oldValue': 8 } }, 'insert': { 'B': 4, 'C': 5 }, - 'remove': { 'F': 9 } - } - } - } + 'remove': { 'F': 9 }, + }, + }, + }, ); }); - it('should work for custom map properties', function () { + it('should work for custom map properties', function() { var rootNode = PropertyFactory.create('autodesk.tests:MapTestNamedPropertyID-1.0.0'); var A = PropertyFactory.create('autodesk.tests:AnonymousMapTestPropertyID-1.0.0'); @@ -1273,7 +1261,7 @@ describe('Reversible ChangeSets', function () { rootNode._properties.map.insert('D', D); testRevAndInvCS( rootNode, - function (myProp) { + function(myProp) { var F = PropertyFactory.create('autodesk.tests:AnonymousMapTestPropertyID-1.0.0'); myProp._properties.map.remove('B'); myProp._properties.map.remove('C'); @@ -1285,21 +1273,21 @@ describe('Reversible ChangeSets', function () { 'map': { 'insert': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { - 'F': { 'String': { 'stringProperty': '' } } - } + 'F': { 'String': { 'stringProperty': '' } }, + }, }, 'remove': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { - 'B': { 'String': { 'stringProperty': '' } }, 'C': { 'String': { 'stringProperty': '' } } - } + 'B': { 'String': { 'stringProperty': '' } }, 'C': { 'String': { 'stringProperty': '' } }, + }, }, 'modify': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { - 'A': { 'String': { 'stringProperty': { 'value': 'hello', 'oldValue': '' } } } - } - } - } - } + 'A': { 'String': { 'stringProperty': { 'value': 'hello', 'oldValue': '' } } }, + }, + }, + }, + }, }, undefined, { @@ -1308,47 +1296,47 @@ describe('Reversible ChangeSets', function () { 'insert': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { 'B': { 'String': { 'stringProperty': '' } }, - 'C': { 'String': { 'stringProperty': '' } } - } + 'C': { 'String': { 'stringProperty': '' } }, + }, }, 'modify': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { - 'A': { 'String': { 'stringProperty': { 'value': '', 'oldValue': 'hello' } } } - } + 'A': { 'String': { 'stringProperty': { 'value': '', 'oldValue': 'hello' } } }, + }, }, 'remove': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { - 'F': { 'String': { 'stringProperty': '' } } - } - } - } - } - } + 'F': { 'String': { 'stringProperty': '' } }, + }, + }, + }, + }, + }, ); }); - it('should test reversible changeset for a NodeProperty', function () { + it('should test reversible changeset for a NodeProperty', function() { var originalChangeSet = { 'insert': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { - 'F': { 'String': { 'stringProperty': '' } } - } + 'F': { 'String': { 'stringProperty': '' } }, + }, }, 'remove': ['B', 'C'], 'modify': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { - 'A': { 'String': { 'stringProperty': 'hello' } } - } - } + 'A': { 'String': { 'stringProperty': 'hello' } }, + }, + }, }; var parentChangeSet = { 'insert': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { 'A': { 'String': { 'stringProperty': '' } }, 'B': { 'String': { 'stringProperty': '' } }, - 'C': { 'String': { 'stringProperty': '' } } - } - } + 'C': { 'String': { 'stringProperty': '' } }, + }, + }, }; var changeSet = new ChangeSet(originalChangeSet); @@ -1357,26 +1345,26 @@ describe('Reversible ChangeSets', function () { expect(changeSet.getSerializedChangeSet()).to.eql({ 'insert': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { - 'F': { 'String': { 'stringProperty': '' } } - } + 'F': { 'String': { 'stringProperty': '' } }, + }, }, 'remove': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { 'B': { 'String': { 'stringProperty': '' } }, - 'C': { 'String': { 'stringProperty': '' } } - } + 'C': { 'String': { 'stringProperty': '' } }, + }, }, 'modify': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { 'A': { 'String': { 'stringProperty': { 'value': 'hello', - 'oldValue': '' - } - } - } - } - } + 'oldValue': '', + }, + }, + }, + }, + }, }); changeSet.toInverseChangeSet(); @@ -1385,25 +1373,25 @@ describe('Reversible ChangeSets', function () { 'insert': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { 'B': { 'String': { 'stringProperty': '' } }, - 'C': { 'String': { 'stringProperty': '' } } - } + 'C': { 'String': { 'stringProperty': '' } }, + }, }, 'remove': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { - 'F': { 'String': { 'stringProperty': '' } } - } + 'F': { 'String': { 'stringProperty': '' } }, + }, }, 'modify': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { 'A': { 'String': { 'stringProperty': { 'value': '', - 'oldValue': 'hello' - } - } - } - } - } + 'oldValue': 'hello', + }, + }, + }, + }, + }, }); var originalChangeSet2 = { @@ -1411,15 +1399,15 @@ describe('Reversible ChangeSets', function () { 'mysample:point2d-1.0.0': { '7485af0e-c992-af6a-ef36-6a024eb4b4e5---2': { 'String': { - 'guid': 'fb5f062f-9f56-55c3-f868-06caa5d8ce26' + 'guid': 'fb5f062f-9f56-55c3-f868-06caa5d8ce26', }, 'Float64': { 'x': 0, - 'y': 0 - } - } - } - } + 'y': 0, + }, + }, + }, + }, }; var parentChangeSet2 = {}; @@ -1435,19 +1423,19 @@ describe('Reversible ChangeSets', function () { 'mysample:point2d-1.0.0': { '7485af0e-c992-af6a-ef36-6a024eb4b4e5---2': { 'String': { - 'guid': 'fb5f062f-9f56-55c3-f868-06caa5d8ce26' + 'guid': 'fb5f062f-9f56-55c3-f868-06caa5d8ce26', }, 'Float64': { 'x': 0, - 'y': 0 - } - } - } - } + 'y': 0, + }, + }, + }, + }, }); }); - it('should test reversible changeset for an array of non primitive types', function () { + it('should test reversible changeset for an array of non primitive types', function() { var originalChangeSet = { 'modify': { 'array': { @@ -1458,16 +1446,16 @@ describe('Reversible ChangeSets', function () { [ { 'Float64': { - 'x': 15.104284463262685 + 'x': 15.104284463262685, }, - 'typeid': 'mysample:point2d-1.0.0' - } - ] - ] - ] - } - } - } + 'typeid': 'mysample:point2d-1.0.0', + }, + ], + ], + ], + }, + }, + }, }; var parentChangeSet = { @@ -1475,13 +1463,13 @@ describe('Reversible ChangeSets', function () { 'mysample:point2d-1.0.0': { 'test': { 'String': { - 'guid': 'cd36cd32-0bd3-5c55-f94c-b95933fdc58b' + 'guid': 'cd36cd32-0bd3-5c55-f94c-b95933fdc58b', }, 'Float64': { 'x': 65.18242364168808, - 'y': 0 - } - } + 'y': 0, + }, + }, }, 'array': { 'test2': { @@ -1491,30 +1479,30 @@ describe('Reversible ChangeSets', function () { [ { 'String': { - 'guid': 'e66540ff-9e5e-d599-033e-d3dd55efc2a3' + 'guid': 'e66540ff-9e5e-d599-033e-d3dd55efc2a3', }, 'Float64': { 'x': 0, - 'y': 0 + 'y': 0, }, - 'typeid': 'mysample:point2d-1.0.0' + 'typeid': 'mysample:point2d-1.0.0', }, { 'String': { - 'guid': 'daeb5439-baef-7986-f90a-6a3a2f082250' + 'guid': 'daeb5439-baef-7986-f90a-6a3a2f082250', }, 'Float64': { 'x': 0, - 'y': 0 + 'y': 0, }, - 'typeid': 'mysample:point2d-1.0.0' - } - ] - ] - ] + 'typeid': 'mysample:point2d-1.0.0', + }, + ], + ], + ], }, - 'test3': {} - } + 'test3': {}, + }, }, 'insertTemplates': { 'mysample:point2d-1.0.0': { @@ -1523,15 +1511,15 @@ describe('Reversible ChangeSets', function () { 'properties': [ { 'id': 'x', - 'typeid': 'Float64' + 'typeid': 'Float64', }, { 'id': 'y', - 'typeid': 'Float64' - } - ] - } - } + 'typeid': 'Float64', + }, + ], + }, + }, }; var changeSet = new ChangeSet(originalChangeSet); @@ -1549,17 +1537,17 @@ describe('Reversible ChangeSets', function () { 'Float64': { 'x': { value: 15.104284463262685, - oldValue: 0 - } + oldValue: 0, + }, }, - 'typeid': 'mysample:point2d-1.0.0' - } - ] - ] - ] - } - } - } + 'typeid': 'mysample:point2d-1.0.0', + }, + ], + ], + ], + }, + }, + }, }); changeSet.toInverseChangeSet(); @@ -1576,51 +1564,51 @@ describe('Reversible ChangeSets', function () { 'Float64': { 'x': { value: 0, - oldValue: 15.104284463262685 - } + oldValue: 15.104284463262685, + }, }, - 'typeid': 'mysample:point2d-1.0.0' - } - ] - ] - ] - } - } - } + 'typeid': 'mysample:point2d-1.0.0', + }, + ], + ], + ], + }, + }, + }, }); }); - it('should correctly reverse inserts of strings', function () { + it('should correctly reverse inserts of strings', function() { let CS = new ChangeSet({ insert: { 'String': { - 'test': 'xxx' - } - } + 'test': 'xxx', + }, + }, }); CS.toInverseChangeSet(); expect(CS.getSerializedChangeSet()).to.deep.equal({ 'remove': { 'String': { - 'test': 'xxx' - } - } + 'test': 'xxx', + }, + }, }); }); - it('should correctly reverse inserts of literal strings within NodeProperties', function () { + it('should correctly reverse inserts of literal strings within NodeProperties', function() { let CS = new ChangeSet({ 'modify': { 'NodeProperty': { 'test': { insert: { 'String': { - 'test': 'xxx' - } - } - } - } - } + 'test': 'xxx', + }, + }, + }, + }, + }, }); CS.toInverseChangeSet(); expect(CS.getSerializedChangeSet()).to.deep.equal({ @@ -1629,16 +1617,16 @@ describe('Reversible ChangeSets', function () { 'test': { 'remove': { 'String': { - 'test': 'xxx' - } - } - } - } - } + 'test': 'xxx', + }, + }, + }, + }, + }, }); }); - it('@regression should not fail when building reversible change sets', function () { + it('@regression should not fail when building reversible change sets', function() { var parentChangeSet = require('./validation/reversibleChangeSetTestData.js').parentChangeSet; var originalChangeSet = require('./validation/reversibleChangeSetTestData.js').originalChangeSet; @@ -1646,7 +1634,7 @@ describe('Reversible ChangeSets', function () { changeSet._toReversibleChangeSet(parentChangeSet); }); - it('@regression should not fail when creating a reversible change set', function () { + it('@regression should not fail when creating a reversible change set', function() { var cs = { 'modify': { 'autodesk.compute:graph-1.0.0': { @@ -1660,7 +1648,7 @@ describe('Reversible ChangeSets', function () { 'a7e7d213-1202-9ee4-a3c1-8a33d6f36122': { 'autodesk.compute:context-1.0.0': { 'computeContext': - { 'Reference': { 'resource': '/8ce10fdd-b2b6-7152-21dc-c0e199b579e3' } } + { 'Reference': { 'resource': '/8ce10fdd-b2b6-7152-21dc-c0e199b579e3' } }, }, 'map': { 'computeNodes': { @@ -1673,27 +1661,27 @@ describe('Reversible ChangeSets', function () { 'computeContext': { 'Reference': { 'resource': - '/c1a811ea-608e-5fcc-1487-c74ab6939dee' - } - } + '/c1a811ea-608e-5fcc-1487-c74ab6939dee', + }, + }, }, 'Reference': { 'inputs.input': '/5eb6ebe1-92c8-52fa-984b-b0b65c46d2a7.computeNodes[a7e7d213-1202-9ee4-a3c1-8a33d6f36122]' + - '.intermediateProperties[2c06da5c-8614-e9c2-3bd6-75ae739eba4f]' - } - } - } - } - } - } - } - } - } - } - } - } - } - } + '.intermediateProperties[2c06da5c-8614-e9c2-3bd6-75ae739eba4f]', + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, }; var parent = { 'insert': { @@ -1708,7 +1696,7 @@ describe('Reversible ChangeSets', function () { 'a7e7d213-1202-9ee4-a3c1-8a33d6f36122': { 'autodesk.compute:context-1.0.0': { 'computeContext': - { 'Reference': { 'resource': '' } } + { 'Reference': { 'resource': '' } }, }, 'map': { 'computeNodes': { @@ -1718,22 +1706,22 @@ describe('Reversible ChangeSets', function () { { 'enum': { 'status': 0 }, 'autodesk.compute:context-1.0.0': { 'computeContext': - { 'Reference': { 'resource': '' } } + { 'Reference': { 'resource': '' } }, }, 'Reference': - { 'inputs.input': '' } - } - } - } - } - } - } - } - } - } - } - } - } - } + { 'inputs.input': '' }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, }; var b = new ChangeSet(cs); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/setup.js b/experimental/PropertyDDS/packages/property-properties/src/test/setup.js index 3ad4e5198546..59430505b01c 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/setup.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/setup.js @@ -14,7 +14,7 @@ if (typeof process === 'object' && Object.prototype.toString.call(process) === ' nock = require('nock'); sinon = require('sinon'); should = chai.should(); - _ = require('lodash') + _ = require('lodash'); isBrowser = false; } else { // We are in the browser. Set up variables like above using served js files. diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/utils.spec.js b/experimental/PropertyDDS/packages/property-properties/src/test/utils.spec.js index 3c5e198e85de..516416e2920c 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/utils.spec.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/utils.spec.js @@ -3,7 +3,7 @@ * Licensed under the MIT License. */ /* globals assert */ -/* eslint-disable no-unused-expressions*/ +/* eslint-disable no-unused-expressions */ /* eslint-disable max-nested-callbacks */ /* eslint-disable max-len */ @@ -12,20 +12,19 @@ * described in /src/utils.js */ +const { ChangeSet } = require('@fluid-experimental/property-changeset'); +const { Utils } = require('@fluid-experimental/property-changeset'); +const { MSG } = require('@fluid-experimental/property-common').constants; const _ = require('lodash'); const { PropertyFactory } = require('..'); const { BaseProperty } = require('..'); const { NodeProperty } = require('../properties/nodeProperty'); -const { Utils } = require('@fluid-experimental/property-changeset'); -const { MSG } = require('@fluid-experimental/property-common').constants; -const { ChangeSet } = require('@fluid-experimental/property-changeset'); -describe('Utils', function () { - - before(function () { +describe('Utils', function() { + before(function() { var TaskStatus = { // inherits : 'Enum', - typeid: 'autodesk.test:utils.spec.task.status-1.0.0' + typeid: 'autodesk.test:utils.spec.task.status-1.0.0', /* values : { running : 'running', created : 'created', @@ -33,7 +32,7 @@ describe('Utils', function () { failed : 'failed', canceled : 'canceled' }, - default : 'created'*/ + default : 'created' */ }; // The subject property template to be tracked @@ -44,9 +43,9 @@ describe('Utils', function () { // {id: 'status', typeid: 'autodesk.test:utils_spec_status-1.0.0'}, { id: 'errorMsg', typeid: 'String' }, // {id: 'result', typeid: 'BaseProperty'}, - { id: 'progress', typeid: 'Uint32', annotation: { min: 0, max: 100 } } + { id: 'progress', typeid: 'Uint32', annotation: { min: 0, max: 100 } }, // {id: 'timeRemaining' , typeid : 'autodesk.test:utils_spec_datedelta-1.0.0'} - ] + ], }; // The observer tracking subject(s) @@ -58,16 +57,16 @@ describe('Utils', function () { { id: 'creator', typeid: 'autodesk.test:utils.spec.user-1.0.0' }, { id: 'subjects', typeid: 'autodesk.test:utils.spec.task.subjectentry-1.0.0', context: 'array' }, { id: 'startTime', typeid: 'autodesk.test:utils.spec.date-1.0.0' }, - { id: 'endTime', typeid: 'autodesk.test:utils.spec.date-1.0.0' } - ] + { id: 'endTime', typeid: 'autodesk.test:utils.spec.date-1.0.0' }, + ], }; // Subject entries passed in to the 'subjects' field of the task observer var TaskSubjectEntries = { typeid: 'autodesk.test:utils.spec.task.subjectentry-1.0.0', properties: [ - { id: 'path', typeid: 'String' } - ] + { id: 'path', typeid: 'String' }, + ], }; // Example usage of task subjects to be tracked @@ -85,64 +84,63 @@ describe('Utils', function () { // { id: 'inputs' , typeid: 'autodesk.test:utils_spec_pan.input-1.0.0' }, - { id: 'thermalResults', typeid: 'autodesk.test:utils.spec.task.subject-1.0.0' }, - { id: 'mechanicalResults', typeid: 'autodesk.test:utils.spec.task.subject-1.0.0' } - ] + { id: 'mechanicalResults', typeid: 'autodesk.test:utils.spec.task.subject-1.0.0' }, + ], }; var nestedTemplate = { typeid: 'autodesk.tests:nestedTemplate-1.0.0', properties: [{ id: 'a', - typeid: 'String' + typeid: 'String', }, { id: 'b', - typeid: 'String' + typeid: 'String', }, { id: 'c', properties: [{ id: 'myNestedProp', - typeid: 'autodesk.test:utils.spec.task.subject-1.0.0' - }] - }] + typeid: 'autodesk.test:utils.spec.task.subject-1.0.0', + }], + }], }; var QuoatablePropertyObject = { typeid: 'autodesk.tests:property.with.quotable.characters-1.0.0', properties: [{ id: 'simple_property', - typeid: 'String' + typeid: 'String', }, { id: 'test.property', - typeid: 'String' + typeid: 'String', }, { id: 'test"property"', - typeid: 'String' + typeid: 'String', }, { id: 'test[property]', properties: [{ id: '.property.', properties: [{ id: 'test', - typeid: 'String' - }] - }] - }] + typeid: 'String', + }], + }], + }], }; var ContainedTemplate = { typeid: 'autodesk.test:utilsTestContained-1.0.0', properties: [ - { id: 'error"Msg"', typeid: 'String' } - ] + { id: 'error"Msg"', typeid: 'String' }, + ], }; var StaticNodeChild = { typeid: 'autodesk.test:staticNodeChild-1.0.0', inherits: ['NodeProperty'], properties: [ - { id: 'nodeProperty', typeid: 'NodeProperty' } - ] + { id: 'nodeProperty', typeid: 'NodeProperty' }, + ], }; var ParentTemplate = { @@ -152,12 +150,12 @@ describe('Utils', function () { { id: 'progress', typeid: 'Uint32' }, { id: 'nested', properties: [ - { id: 'en"t"ry', typeid: 'String' } - ] + { id: 'en"t"ry', typeid: 'String' }, + ], }, { id: 'contained', typeid: 'autodesk.test:utilsTestContained-1.0.0' }, - { id: 'containedMap', typeid: 'autodesk.test:utilsTestContained-1.0.0', context: 'map' } - ] + { id: 'containedMap', typeid: 'autodesk.test:utilsTestContained-1.0.0', context: 'map' }, + ], }; PropertyFactory._reregister(TaskStatus); @@ -172,9 +170,9 @@ describe('Utils', function () { PropertyFactory._reregister(StaticNodeChild); }); - describe('Utils.traverseChangeSetRecursively', function () { + describe('Utils.traverseChangeSetRecursively', function() { var testRoot, contexts, namedNodePropForSet; - it('should report correctly for inserts', function () { + it('should report correctly for inserts', function() { testRoot = PropertyFactory.create('NodeProperty'); testRoot.insert('string', PropertyFactory.create('String')); testRoot.insert('test"Templated"Property', @@ -244,7 +242,7 @@ describe('Utils', function () { contexts = []; Utils.traverseChangeSetRecursively(testRoot.serialize({ 'dirtyOnly': false }), { - preCallback: function (in_context) { + preCallback: function(in_context) { // Do some basic sanity checks var node = testRoot.resolvePath(in_context.getFullPath() + '*'); expect(node).to.be.instanceof(BaseProperty); @@ -257,12 +255,12 @@ describe('Utils', function () { } contexts.push(in_context.clone()); - } + }, }); expect(contexts.length).to.equal(38); }); - it('should work for modifications of primitive types', function () { + it('should work for modifications of primitive types', function() { // Clean the old modifications testRoot.cleanDirty(); @@ -290,7 +288,7 @@ describe('Utils', function () { var reportedStringModifiedCount = 0; Utils.traverseChangeSetRecursively(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context) { + preCallback: function(in_context) { // Do some basic sanity checks var node = testRoot.resolvePath(in_context.getFullPath()); expect(node).to.be.instanceof(BaseProperty); @@ -304,28 +302,28 @@ describe('Utils', function () { if (in_context.getTypeid() === 'array') { expect(in_context.getNestedChangeSet()).to.deep.equal({ - insert: [[5, [15]]] + insert: [[5, [15]]], }); } if (in_context.getTypeid() === 'map') { expect(in_context.getNestedChangeSet()).to.deep.equal({ insert: { - new_test: 7 + new_test: 7, }, modify: { - test: 5 - } + test: 5, + }, }); } - } + }, }); // Make sure all modified strings have been reported expect(reportedStringModifiedCount).to.equal(modifiedStringCount); }); - it('should work for inserts in strings', function () { + it('should work for inserts in strings', function() { // Clean the old modifications testRoot.cleanDirty(); @@ -339,7 +337,7 @@ describe('Utils', function () { } Utils.traverseChangeSetRecursively(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context) { + preCallback: function(in_context) { // Do some basic sanity checks var node = testRoot.resolvePath(in_context.getFullPath()); expect(node).to.be.instanceof(BaseProperty); @@ -348,14 +346,14 @@ describe('Utils', function () { if (node.getTypeid() === 'String') { expect(in_context.getNestedChangeSet()).to.deep.equal({ - insert: [[3, '_inserted_']] + insert: [[3, '_inserted_']], }); } - } + }, }); }); - it('should work for inserts in arrays', function () { + it('should work for inserts in arrays', function() { // Clean the old modifications testRoot.cleanDirty(); @@ -365,7 +363,7 @@ describe('Utils', function () { newArrayNode._properties.string.value = 'test'; Utils.traverseChangeSetRecursively(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context) { + preCallback: function(in_context) { // Do some basic sanity checks var node = testRoot.resolvePath(in_context.getFullPath()); expect(node).to.be.instanceof(BaseProperty); @@ -381,11 +379,11 @@ describe('Utils', function () { if (node.getTypeid() === 'String') { expect(in_context.getNestedChangeSet()).to.equal('test'); } - } + }, }); }); - it('should work for inserts in sets', function () { + it('should work for inserts in sets', function() { // Clean the old modifications testRoot.cleanDirty(); @@ -395,7 +393,7 @@ describe('Utils', function () { newSetNode._properties.string.setValue('test'); Utils.traverseChangeSetRecursively(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context) { + preCallback: function(in_context) { // Do some basic sanity checks var node = testRoot.resolvePath(in_context.getFullPath()); expect(node).to.be.instanceof(BaseProperty); @@ -411,11 +409,11 @@ describe('Utils', function () { if (node.getTypeid() === 'String') { expect(in_context.getNestedChangeSet()).to.equal(node.value); } - } + }, }); }); - it('should work for node property removals', function () { + it('should work for node property removals', function() { // Clean the old modifications testRoot.cleanDirty(); @@ -431,7 +429,7 @@ describe('Utils', function () { var actualStringRemoveCount = 0; Utils.traverseChangeSetRecursively(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context) { + preCallback: function(in_context) { var node = testRoot.resolvePath(in_context.getFullPath()); if (node) { expect(in_context.getOperationType()).to.equal('modify'); @@ -440,19 +438,19 @@ describe('Utils', function () { expect(removedStrings.indexOf('/' + in_context.getFullPath())).to.not.equal(-1); actualStringRemoveCount++; } - } + }, }); expect(removedStrings.length).to.equal(actualStringRemoveCount); }); - it('should work for array removals', function () { + it('should work for array removals', function() { // Clean the old modifications testRoot.cleanDirty(); testRoot._properties.array.removeRange(0, 2); var arrayRemovalCount = 0; Utils.traverseChangeSetRecursively(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context) { + preCallback: function(in_context) { if (in_context.getFullPath() === '' || in_context.getFullPath() === 'array') { expect(in_context.getOperationType()).to.equal('modify'); @@ -460,19 +458,19 @@ describe('Utils', function () { expect(in_context.getOperationType()).to.equal('remove'); arrayRemovalCount++; } - } + }, }); expect(arrayRemovalCount).to.equal(2); }); - it('should work for map removals', function () { + it('should work for map removals', function() { // Clean the old modifications testRoot.cleanDirty(); testRoot._properties.map.remove('string'); var mapRemovalCount = 0; Utils.traverseChangeSetRecursively(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context) { + preCallback: function(in_context) { if (in_context.getFullPath() === '' || in_context.getFullPath() === 'map') { expect(in_context.getOperationType()).to.equal('modify'); @@ -480,12 +478,12 @@ describe('Utils', function () { expect(in_context.getOperationType()).to.equal('remove'); mapRemovalCount++; } - } + }, }); expect(mapRemovalCount).to.equal(1); }); - it('should work for set removals', function () { + it('should work for set removals', function() { // Clean the old modifications testRoot.cleanDirty(); @@ -493,7 +491,7 @@ describe('Utils', function () { var setRemovalCount = 0; Utils.traverseChangeSetRecursively(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context) { + preCallback: function(in_context) { if (in_context.getFullPath() === '' || in_context.getFullPath() === 'set') { expect(in_context.getOperationType()).to.equal('modify'); @@ -501,12 +499,12 @@ describe('Utils', function () { expect(in_context.getOperationType()).to.equal('remove'); setRemovalCount++; } - } + }, }); expect(setRemovalCount).to.equal(1); }); - it('should clone the context correctly', function () { + it('should clone the context correctly', function() { testRoot.insert('setClone', PropertyFactory.create('set<>')); var namedNodePropForSet1 = PropertyFactory.create('NamedNodeProperty'); var namedNodePropForSet2 = PropertyFactory.create('NamedNodeProperty'); @@ -527,7 +525,7 @@ describe('Utils', function () { var setRemovalCount = 0; var contextCloneCount = 0; Utils.traverseChangeSetRecursively(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context) { + preCallback: function(in_context) { if (in_context.getFullPath() === '' || in_context.getFullPath() === 'setClone') { expect(in_context.getOperationType()).to.equal('modify'); @@ -538,32 +536,32 @@ describe('Utils', function () { var cloneContext = in_context.clone(); expect(cloneContext).to.deep.equal(in_context); contextCloneCount++; - } + }, }); expect(setRemovalCount).to.equal(3); expect(contextCloneCount >= 3).to.be.true; // we should clone at least 3 times (probably more) }); - it('@regression should work when replacing a map element', function () { + it('@regression should work when replacing a map element', function() { // Clean the old modifications testRoot.cleanDirty(); testRoot._properties.map.set('nodeProperty', PropertyFactory.create('NamedNodeProperty')); var operationtypes = []; Utils.traverseChangeSetRecursively(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context) { + preCallback: function(in_context) { // expect operations to be 'remove' and 'insert' if (in_context.getFullPath() === 'map[nodeProperty]') { operationtypes.push(in_context.getOperationType()); } - } + }, }); expect(operationtypes).to.deep.equal(['remove', 'insert']); }); }); - describe('Utils.traverseChangeSetRecursivelyAsync', function () { + describe('Utils.traverseChangeSetRecursivelyAsync', function() { var testRoot, contexts, namedNodePropForSet; - it('should report correctly for inserts', function (done) { + it('should report correctly for inserts', function(done) { testRoot = PropertyFactory.create('NodeProperty'); testRoot.insert('string', PropertyFactory.create('String')); testRoot.insert('test"Templated"Property', @@ -633,7 +631,7 @@ describe('Utils', function () { contexts = []; Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ 'dirtyOnly': false }), { - preCallback: function (in_context, cb) { + preCallback: function(in_context, cb) { // Do some basic sanity checks var node = testRoot.resolvePath(in_context.getFullPath() + '*'); expect(node).to.be.instanceof(BaseProperty); @@ -647,14 +645,14 @@ describe('Utils', function () { contexts.push(in_context.clone()); setImmediate(cb); - } - }, function () { + }, + }, function() { expect(contexts.length).to.equal(38); done(); }); }); - it('should work for modifications of primitive types', function (done) { + it('should work for modifications of primitive types', function(done) { // Clean the old modifications testRoot.cleanDirty(); @@ -682,7 +680,7 @@ describe('Utils', function () { var reportedStringModifiedCount = 0; Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context, cb) { + preCallback: function(in_context, cb) { // Do some basic sanity checks var node = testRoot.resolvePath(in_context.getFullPath()); expect(node).to.be.instanceof(BaseProperty); @@ -696,30 +694,30 @@ describe('Utils', function () { if (in_context.getTypeid() === 'array') { expect(in_context.getNestedChangeSet()).to.deep.equal({ - insert: [[5, [15]]] + insert: [[5, [15]]], }); } if (in_context.getTypeid() === 'map') { expect(in_context.getNestedChangeSet()).to.deep.equal({ insert: { - new_test: 7 + new_test: 7, }, modify: { - test: 5 - } + test: 5, + }, }); } setImmediate(cb); - } - }, function () { + }, + }, function() { // Make sure all modified strings have been reported expect(reportedStringModifiedCount).to.equal(modifiedStringCount); done(); }); }); - it('should work for inserts in strings', function (done) { + it('should work for inserts in strings', function(done) { // Clean the old modifications testRoot.cleanDirty(); @@ -733,7 +731,7 @@ describe('Utils', function () { } Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context, cb) { + preCallback: function(in_context, cb) { // Do some basic sanity checks var node = testRoot.resolvePath(in_context.getFullPath()); expect(node).to.be.instanceof(BaseProperty); @@ -742,17 +740,17 @@ describe('Utils', function () { if (node.getTypeid() === 'String') { expect(in_context.getNestedChangeSet()).to.deep.equal({ - insert: [[3, '_inserted_']] + insert: [[3, '_inserted_']], }); } setImmediate(cb); - } - }, function () { + }, + }, function() { done(); }); }); - it('should work for inserts in arrays', function (done) { + it('should work for inserts in arrays', function(done) { // Clean the old modifications testRoot.cleanDirty(); @@ -762,7 +760,7 @@ describe('Utils', function () { newArrayNode._properties.string.value = 'test'; Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context, cb) { + preCallback: function(in_context, cb) { // Do some basic sanity checks var node = testRoot.resolvePath(in_context.getFullPath()); expect(node).to.be.instanceof(BaseProperty); @@ -779,13 +777,13 @@ describe('Utils', function () { expect(in_context.getNestedChangeSet()).to.equal('test'); } setImmediate(cb); - } - }, function () { + }, + }, function() { done(); }); }); - it('should work for inserts in sets', function (done) { + it('should work for inserts in sets', function(done) { // Clean the old modifications testRoot.cleanDirty(); @@ -795,7 +793,7 @@ describe('Utils', function () { newSetNode._properties.string.setValue('test'); Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context, cb) { + preCallback: function(in_context, cb) { // Do some basic sanity checks var node = testRoot.resolvePath(in_context.getFullPath()); expect(node).to.be.instanceof(BaseProperty); @@ -812,11 +810,11 @@ describe('Utils', function () { expect(in_context.getNestedChangeSet()).to.equal(node.value); } setImmediate(cb); - } + }, }, done); }); - it('should work for node property removals', function (done) { + it('should work for node property removals', function(done) { // Clean the old modifications testRoot.cleanDirty(); @@ -832,7 +830,7 @@ describe('Utils', function () { var actualStringRemoveCount = 0; Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context, cb) { + preCallback: function(in_context, cb) { var node = testRoot.resolvePath(in_context.getFullPath()); if (node) { expect(in_context.getOperationType()).to.equal('modify'); @@ -842,21 +840,21 @@ describe('Utils', function () { actualStringRemoveCount++; } setImmediate(cb); - } - }, function () { + }, + }, function() { expect(removedStrings.length).to.equal(actualStringRemoveCount); done(); }); }); - it('should work for array removals', function (done) { + it('should work for array removals', function(done) { // Clean the old modifications testRoot.cleanDirty(); testRoot._properties.array.removeRange(0, 2); var arrayRemovalCount = 0; Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context, cb) { + preCallback: function(in_context, cb) { if (in_context.getFullPath() === '' || in_context.getFullPath() === 'array') { expect(in_context.getOperationType()).to.equal('modify'); @@ -865,21 +863,21 @@ describe('Utils', function () { arrayRemovalCount++; } setImmediate(cb); - } - }, function () { + }, + }, function() { expect(arrayRemovalCount).to.equal(2); done(); }); }); - it('should work for map removals', function (done) { + it('should work for map removals', function(done) { // Clean the old modifications testRoot.cleanDirty(); testRoot._properties.map.remove('string'); var mapRemovalCount = 0; Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context, cb) { + preCallback: function(in_context, cb) { if (in_context.getFullPath() === '' || in_context.getFullPath() === 'map') { expect(in_context.getOperationType()).to.equal('modify'); @@ -888,14 +886,14 @@ describe('Utils', function () { mapRemovalCount++; } setImmediate(cb); - } - }, function () { + }, + }, function() { expect(mapRemovalCount).to.equal(1); done(); }); }); - it('should work for set removals', function (done) { + it('should work for set removals', function(done) { // Clean the old modifications testRoot.cleanDirty(); @@ -903,7 +901,7 @@ describe('Utils', function () { var setRemovalCount = 0; Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context, cb) { + preCallback: function(in_context, cb) { if (in_context.getFullPath() === '' || in_context.getFullPath() === 'set') { expect(in_context.getOperationType()).to.equal('modify'); @@ -912,14 +910,14 @@ describe('Utils', function () { setRemovalCount++; } setImmediate(cb); - } - }, function () { + }, + }, function() { expect(setRemovalCount).to.equal(1); done(); }); }); - it('should clone the context correctly', function (done) { + it('should clone the context correctly', function(done) { testRoot.insert('setClone', PropertyFactory.create('set<>')); var namedNodePropForSet1 = PropertyFactory.create('NamedNodeProperty'); var namedNodePropForSet2 = PropertyFactory.create('NamedNodeProperty'); @@ -940,7 +938,7 @@ describe('Utils', function () { var setRemovalCount = 0; var contextCloneCount = 0; Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context, cb) { + preCallback: function(in_context, cb) { if (in_context.getFullPath() === '' || in_context.getFullPath() === 'setClone') { expect(in_context.getOperationType()).to.equal('modify'); @@ -952,15 +950,15 @@ describe('Utils', function () { expect(cloneContext).to.deep.equal(in_context); contextCloneCount++; setImmediate(cb); - } - }, function () { + }, + }, function() { expect(setRemovalCount).to.equal(3); expect(contextCloneCount >= 3).to.be.true; // we should clone at least 3 times (probably more) done(); }); }); - it('@regression should work for mixed modifications and removals', function (done) { + it('@regression should work for mixed modifications and removals', function(done) { // This test uses its own property sets tree var ownRoot = PropertyFactory.create('NodeProperty'); var userInfo = PropertyFactory.create('NodeProperty'); @@ -979,7 +977,7 @@ describe('Utils', function () { var modifiedCount = 0; var serializedCS = ownRoot.serialize({ 'dirtyOnly': true }); Utils.traverseChangeSetRecursivelyAsync(serializedCS, { - preCallback: function (in_context, cb) { + preCallback: function(in_context, cb) { var node = ownRoot.resolvePath(in_context.getFullPath()); if (node) { expect(in_context.getOperationType()).to.equal('modify'); @@ -992,15 +990,14 @@ describe('Utils', function () { expect(in_context.getLastSegment()).to.equal('isResident'); } setImmediate(cb); - } - }, function () { + }, + }, function() { expect(modifiedCount).to.equal(2); done(); }); - }); - it('@regression should work when replacing a map element', function (done) { + it('@regression should work when replacing a map element', function(done) { // Clean the old modifications testRoot.cleanDirty(); @@ -1009,7 +1006,7 @@ describe('Utils', function () { var operations = []; Utils.traverseChangeSetRecursivelyAsync(testRoot.serialize({ 'dirtyOnly': true }), { - preCallback: function (in_context, cb) { + preCallback: function(in_context, cb) { if (in_context.getFullPath() === 'map[testParent]') { operations.push(in_context.getOperationType()); } else if (in_context.getFullPath() === 'map[testParent].errorMsg') { @@ -1018,16 +1015,15 @@ describe('Utils', function () { expect(in_context.getNestedChangeSet() === 99); } setImmediate(cb); - } - }, function () { + }, + }, function() { expect(operations).to.deep.equal(['remove', 'insert']); done(); }); }); }); - describe('Utils.enumerateSchemas', function () { - + describe('Utils.enumerateSchemas', function() { var serializedChangeSet = { 'insertTemplates': { 'autodesk.tests:property.set.SimpleNamedPoint-1.0.0': { @@ -1035,23 +1031,23 @@ describe('Utils', function () { inherits: 'NamedProperty', properties: [ { id: 'x', typeid: 'Uint32' }, - { id: 'y', typeid: 'Uint32' } - ] + { id: 'y', typeid: 'Uint32' }, + ], }, 'autodesk.tests:property.set.SimpleNamedPoint-1.2.0': { typeid: 'autodesk.tests:property.set.SimpleNamedPoint-1.0.0', inherits: 'NamedProperty', properties: [ { id: 'x', typeid: 'Uint64' }, - { id: 'y', typeid: 'Uint64' } - ] - } - } + { id: 'y', typeid: 'Uint64' }, + ], + }, + }, }; - it('should return the schemas, and then call the finalizer', function (done) { + it('should return the schemas, and then call the finalizer', function(done) { var countedTemplates = 0; - Utils.enumerateSchemas(serializedChangeSet, function (t, cb) { + Utils.enumerateSchemas(serializedChangeSet, function(t, cb) { countedTemplates++; if (t.key === 'autodesk.tests:property.set.SimpleNamedPoint-1.0.0') { expect(t.value).to.eql(serializedChangeSet.insertTemplates['autodesk.tests:property.set.SimpleNamedPoint-1.0.0']); @@ -1060,15 +1056,15 @@ describe('Utils', function () { expect(t.value).to.eql(serializedChangeSet.insertTemplates['autodesk.tests:property.set.SimpleNamedPoint-1.2.0']); } setImmediate(cb); - }, function () { + }, function() { expect(countedTemplates).to.eql(2); done(); }); }); }); - describe('Utils.extractTypeids', function () { - it('Should work for a simple templated property', function () { + describe('Utils.extractTypeids', function() { + it('Should work for a simple templated property', function() { var property = PropertyFactory.create('autodesk.test:utilsTestParent-1.0.0'); var typeids = Utils.extractTypeids(property.serialize({ 'dirtyOnly': false, 'includeRootTypeid': true })); @@ -1079,7 +1075,7 @@ describe('Utils', function () { 'map']); }); - it('Should work for inserts into a NodePropertý', function () { + it('Should work for inserts into a NodePropertý', function() { var property = PropertyFactory.create('NodeProperty'); var child = PropertyFactory.create('autodesk.test:utilsTestParent-1.0.0'); property.insert('child', child); @@ -1091,7 +1087,7 @@ describe('Utils', function () { 'map']); }); - it('Should work for inserts into a map', function () { + it('Should work for inserts into a map', function() { var property = PropertyFactory.create('map<>'); var child = PropertyFactory.create('autodesk.test:utilsTestParent-1.0.0'); property.insert('child', child); @@ -1104,7 +1100,7 @@ describe('Utils', function () { 'map']); }); - it('Should work for inserts into an array', function () { + it('Should work for inserts into an array', function() { var property = PropertyFactory.create('array<>'); var child = PropertyFactory.create('autodesk.test:utilsTestParent-1.0.0'); property.push(child); @@ -1117,7 +1113,7 @@ describe('Utils', function () { 'map']); }); - it('Should work for modifications of a NodeProperty', function () { + it('Should work for modifications of a NodeProperty', function() { var property = PropertyFactory.create('NodeProperty'); var child = PropertyFactory.create('autodesk.test:utilsTestParent-1.0.0'); property.insert('child', child); @@ -1127,11 +1123,11 @@ describe('Utils', function () { var typeids = Utils.extractTypeids(property.serialize({ 'dirtyOnly': true, 'in_includeRootTypeid': true })); typeids.sort(); expect(typeids).to.deep.equal([ - 'NodeProperty', 'String', 'autodesk.test:utilsTestContained-1.0.0', 'autodesk.test:utilsTestParent-1.0.0' + 'NodeProperty', 'String', 'autodesk.test:utilsTestContained-1.0.0', 'autodesk.test:utilsTestParent-1.0.0', ]); }); - it('Should work for modifications of a map', function () { + it('Should work for modifications of a map', function() { var property = PropertyFactory.create('map<>'); var child = PropertyFactory.create('autodesk.test:utilsTestParent-1.0.0'); property.insert('child', child); @@ -1141,11 +1137,11 @@ describe('Utils', function () { var typeids = Utils.extractTypeids(property._serialize(true, true)); typeids.sort(); expect(typeids).to.deep.equal([ - 'String', 'autodesk.test:utilsTestContained-1.0.0', 'autodesk.test:utilsTestParent-1.0.0', 'map<>' + 'String', 'autodesk.test:utilsTestContained-1.0.0', 'autodesk.test:utilsTestParent-1.0.0', 'map<>', ]); }); - it('Should work for modifications of an array', function () { + it('Should work for modifications of an array', function() { var property = PropertyFactory.create('array<>'); var child = PropertyFactory.create('autodesk.test:utilsTestParent-1.0.0'); property.push(child); @@ -1155,11 +1151,11 @@ describe('Utils', function () { var typeids = Utils.extractTypeids(property._serialize(true, true)); typeids.sort(); expect(typeids).to.deep.equal([ - 'String', 'array<>', 'autodesk.test:utilsTestContained-1.0.0', 'autodesk.test:utilsTestParent-1.0.0' + 'String', 'array<>', 'autodesk.test:utilsTestContained-1.0.0', 'autodesk.test:utilsTestParent-1.0.0', ]); }); - it('Should work for removals', function () { + it('Should work for removals', function() { var typeids = Utils.extractTypeids({ remove: ['xxx-yyy-zzz'] }); expect(typeids).to.have.lengthOf(1); @@ -1167,10 +1163,10 @@ describe('Utils', function () { }); }); - describe('Change set helper functions', function () { + describe('Change set helper functions', function() { var root, sim, subject1, subject2, subject3; // Create a simple test data-set - before(function () { + before(function() { root = PropertyFactory.create('NodeProperty'); sim = PropertyFactory.create('autodesk.test:utils.spec.pan.sim-1.0.0'); subject1 = PropertyFactory.create('autodesk.test:utils.spec.task.subject-1.0.0'); @@ -1191,7 +1187,7 @@ describe('Utils', function () { mapProp.insert('entry', PropertyFactory.create('autodesk.test:utils.spec.task.subject-1.0.0')); }); - it('should work correctly for inserts', function () { + it('should work correctly for inserts', function() { var insertedResults = Utils.getChangesByType('autodesk.test:utils.spec.task.subject-1.0.0', root.serialize({ 'dirtyOnly': true })); assert(_.keys(insertedResults.insert).length === 9); @@ -1202,12 +1198,12 @@ describe('Utils', function () { } }); - it('should work correctly for the root path', function () { + it('should work correctly for the root path', function() { var AnonymousTestPropertyTemplate = { typeid: 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0', properties: [ - { id: 'stringProperty', typeid: 'String' } - ] + { id: 'stringProperty', typeid: 'String' }, + ], }; PropertyFactory._reregister(AnonymousTestPropertyTemplate); @@ -1222,16 +1218,16 @@ describe('Utils', function () { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { 'A': { 'String': { - 'stringProperty': '' - } - } - } - } - } + 'stringProperty': '', + }, + }, + }, + }, + }, }); }); - it('should correctly strip typeids in insertions', function () { + it('should correctly strip typeids in insertions', function() { var insertionChangeSet = root.serialize({ 'dirtyOnly': true }); Utils._stripTypeids(insertionChangeSet); expect(insertionChangeSet).to.deep.equal({ @@ -1240,54 +1236,54 @@ describe('Utils', function () { 'insert': { 'subject1': { 'errorMsg': '', - 'progress': 0 + 'progress': 0, }, 'subject2': { 'errorMsg': '', - 'progress': 0 - } + 'progress': 0, + }, }, 'costEstimated': { 'errorMsg': '', - 'progress': 0 + 'progress': 0, }, 'costFinal': { 'errorMsg': '', - 'progress': 0 + 'progress': 0, }, 'thermalResults': { 'errorMsg': '', - 'progress': 0 + 'progress': 0, }, 'mechanicalResults': { 'errorMsg': '', - 'progress': 0 + 'progress': 0, }, 'start': false, - 'cancel': false + 'cancel': false, }, 'map': { 'insert': { 'entry': { 'errorMsg': '', - 'progress': 0 - } - } + 'progress': 0, + }, + }, }, 'array': { 'insert': [[0, [{ 'errorMsg': '', - 'progress': 0 + 'progress': 0, }, { 'errorMsg': '', - 'progress': 1 - }]]] - } - } + 'progress': 1, + }]]], + }, + }, }); }); - it('should work correctly for modifies', function () { + it('should work correctly for modifies', function() { root.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE | BaseProperty.MODIFIED_STATE_FLAGS.DIRTY); subject3 = PropertyFactory.create('autodesk.test:utils.spec.task.subject-1.0.0'); @@ -1297,17 +1293,16 @@ describe('Utils', function () { subject2._properties.errorMsg.value = 'test'; sim._properties.thermalResults.errorMsg.value = 'test44'; - // Test array modification root.resolvePath('array[1].errorMsg').value = 'test'; // Test array insertion root.resolvePath('array').insertRange(1, [ PropertyFactory.create('autodesk.test:utils.spec.task.subject-1.0.0'), - PropertyFactory.create('autodesk.test:utils.spec.task.subject-1.0.0') + PropertyFactory.create('autodesk.test:utils.spec.task.subject-1.0.0'), ]); root.resolvePath('array').insertRange(0, [ - PropertyFactory.create('autodesk.test:utils.spec.task.subject-1.0.0') + PropertyFactory.create('autodesk.test:utils.spec.task.subject-1.0.0'), ]); // Test map modification @@ -1320,7 +1315,7 @@ describe('Utils', function () { var modifiedResults = Utils.getChangesByType( 'autodesk.test:utils.spec.task.subject-1.0.0', root.serialize({ 'dirtyOnly': true }), - true + true, ); assert(_.keys(modifiedResults.insert).length === 5); @@ -1336,7 +1331,7 @@ describe('Utils', function () { } }); - it('should correctly strip typeids in modifies', function () { + it('should correctly strip typeids in modifies', function() { var modifyChangeSet = root.serialize({ 'dirtyOnly': true }); Utils._stripTypeids(modifyChangeSet); expect(modifyChangeSet).to.deep.equal({ @@ -1344,59 +1339,59 @@ describe('Utils', function () { 'simulation': { 'modify': { 'subject1': { - 'errorMsg': 'test' + 'errorMsg': 'test', }, 'subject2': { 'insert': { 'subject3': { 'errorMsg': '', - 'progress': 0 - } + 'progress': 0, + }, }, - 'errorMsg': 'test' - } + 'errorMsg': 'test', + }, }, 'thermalResults': { - 'errorMsg': 'test44' - } + 'errorMsg': 'test44', + }, }, 'array': { insert: [[0, [ { 'errorMsg': '', - 'progress': 0 - } + 'progress': 0, + }, ]], [1, [ { 'errorMsg': '', - 'progress': 0 + 'progress': 0, }, { 'errorMsg': '', - 'progress': 0 - } + 'progress': 0, + }, ]]], modify: [[1, [{ - 'errorMsg': 'test' - }]]] + 'errorMsg': 'test', + }]]], }, 'map': { 'insert': { 'entry2': { 'errorMsg': '', - 'progress': 0 - } + 'progress': 0, + }, }, 'modify': { 'entry': { - 'errorMsg': 'test' - } - } - } - } + 'errorMsg': 'test', + }, + }, + }, + }, }); }); - it('should correctly work for removes', function () { + it('should correctly work for removes', function() { root.cleanDirty(BaseProperty.MODIFIED_STATE_FLAGS.PENDING_CHANGE | BaseProperty.MODIFIED_STATE_FLAGS.DIRTY); subject2.remove(subject3.getId()); @@ -1415,23 +1410,23 @@ describe('Utils', function () { root.resolvePath('array').removeRange(1, 2); }); - it('should correctly strip typeids in removes', function () { + it('should correctly strip typeids in removes', function() { var modifyChangeSet = root._serialize(true); Utils._stripTypeids(modifyChangeSet); expect(modifyChangeSet).to.deep.equal({ 'modify': { 'array': { - 'remove': [[0, 1], [2, 2]] + 'remove': [[0, 1], [2, 2]], }, 'map': { - 'remove': ['entry2'] - } + 'remove': ['entry2'], + }, }, - 'remove': ['simulation'] + 'remove': ['simulation'], }); }); - it('should work for nested templates', function () { + it('should work for nested templates', function() { var nestedTemplate = PropertyFactory.create('autodesk.tests:nestedTemplate-1.0.0'); nestedTemplate._properties.c.myNestedProp.errorMsg.value = 'testString'; var changeSet = nestedTemplate._serialize(true); @@ -1443,7 +1438,7 @@ describe('Utils', function () { nestedTemplate, changeSet, false)).to.have.keys('modify'); }); - it('should work for an object with characters that have to be quoted', function () { + it('should work for an object with characters that have to be quoted', function() { var node = PropertyFactory.create('autodesk.tests:property.with.quotable.characters-1.0.0'); node.get('simple_property').value = 'test'; node.get('test.property').value = 'test'; @@ -1464,7 +1459,7 @@ describe('Utils', function () { node, changeSet, false)).to.have.keys('modify'); }); - it('should work for a node property with characters that have to be quoted', function () { + it('should work for a node property with characters that have to be quoted', function() { var node = PropertyFactory.create('NodeProperty'); node.insert('simple_property', PropertyFactory.create('String', undefined, 'test')); node.insert('test.property', PropertyFactory.create('String', undefined, 'test')); @@ -1489,7 +1484,7 @@ describe('Utils', function () { }); }); - describe('Utils.getChangesToTokenizedPaths', function () { + describe('Utils.getChangesToTokenizedPaths', function() { var CS = { 'insert': { 'NodeProperty': { @@ -1500,14 +1495,14 @@ describe('Utils', function () { 'insert': { 'String': { 'string': 'text', - '__doubleUnderscore': 'text' - } - } - } - } - } + '__doubleUnderscore': 'text', + }, + }, + }, + }, + }, }, - 'nested2': {} + 'nested2': {}, }, 'array<>': { 'nestedArray': { @@ -1516,28 +1511,28 @@ describe('Utils', function () { 0, [ { - 'typeid': 'NodeProperty' + 'typeid': 'NodeProperty', }, { 'typeid': 'NodeProperty', 'insert': { 'String': { - 'text': '' - } - } - } - ] - ] - ] - } + 'text': '', + }, + }, + }, + ], + ], + ], + }, }, 'String': { - 'string': 'text' - } - } + 'string': 'text', + }, + }, }; - it('should work using objects', function () { + it('should work using objects', function() { var visitedPaths = []; Utils.getChangesToTokenizedPaths({ 'String': {}, @@ -1545,19 +1540,19 @@ describe('Utils', function () { 'nested2': { 'string': { '__hidden': { - 'myCallback': function () { return 'hello'; }, - 'myValue': 1 - } + 'myCallback': function() { return 'hello'; }, + 'myValue': 1, + }, }, - '___doubleUnderscore': {} // Yes, there are 3 '_', as escapeLeadingDoubleUnderscore = true - } + '___doubleUnderscore': {}, // Yes, there are 3 '_', as escapeLeadingDoubleUnderscore = true + }, }, 'nestedArray': { '1': { - 'String': {} - } - } - }, CS, function (in_context, in_nested, in_tokenizedPath) { + 'String': {}, + }, + }, + }, CS, function(in_context, in_nested, in_tokenizedPath) { var currentPath = in_tokenizedPath.join('.'); visitedPaths.push(currentPath); if (currentPath === 'nested1.nested2.string') { @@ -1570,13 +1565,13 @@ describe('Utils', function () { }, { rootOperation: 'modify', rootTypeid: 'NodeProperty', - escapeLeadingDoubleUnderscore: true + escapeLeadingDoubleUnderscore: true, }); expect(visitedPaths).to.deep.equal(['', 'nested1', 'nested1.nested2', 'nested1.nested2.string', 'nested1.nested2.__doubleUnderscore', 'nestedArray', 'nestedArray.1']); }); - it('should work using maps', function () { + it('should work using maps', function() { var visitedPaths = []; Utils.getChangesToTokenizedPaths(new Map([ ['String', new Map()], @@ -1584,19 +1579,19 @@ describe('Utils', function () { ['nested2', new Map([ ['string', new Map([ ['__hidden', new Map([ - ['myCallback', function () { return 'hello'; }], - ['myValue', 1] - ])] + ['myCallback', function() { return 'hello'; }], + ['myValue', 1], + ])], ])], - ['___doubleUnderscore', new Map()] // Yes, there are 3 '_', as escapeLeadingDoubleUnderscore = true - ])] + ['___doubleUnderscore', new Map()], // Yes, there are 3 '_', as escapeLeadingDoubleUnderscore = true + ])], ])], ['nestedArray', new Map([ ['1', new Map([ - ['String', new Map()] - ])] - ])] - ]), CS, function (in_context, in_nested, in_tokenizedPath) { + ['String', new Map()], + ])], + ])], + ]), CS, function(in_context, in_nested, in_tokenizedPath) { var currentPath = in_tokenizedPath.join('.'); visitedPaths.push(currentPath); if (currentPath === 'nested1.nested2.string') { @@ -1609,26 +1604,26 @@ describe('Utils', function () { }, { rootOperation: 'modify', rootTypeid: 'NodeProperty', - escapeLeadingDoubleUnderscore: true + escapeLeadingDoubleUnderscore: true, }); expect(visitedPaths).to.deep.equal(['', 'nested1', 'nested1.nested2', 'nested1.nested2.string', 'nested1.nested2.__doubleUnderscore', 'nestedArray', 'nestedArray.1']); }); - it('should assume paths as literal when the escapeLeadingDoubleUnderscore flag is off ', function () { + it('should assume paths as literal when the escapeLeadingDoubleUnderscore flag is off ', function() { var visitedPaths = []; Utils.getChangesToTokenizedPaths({ 'nested1': { 'nested2': { - '__doubleUnderscore': {} // The amount of underscores is the same as in the changeSet - } - } - }, CS, function (in_context, in_nested, in_tokenizedPath) { + '__doubleUnderscore': {}, // The amount of underscores is the same as in the changeSet + }, + }, + }, CS, function(in_context, in_nested, in_tokenizedPath) { visitedPaths.push(in_tokenizedPath.join('.')); }, { rootOperation: 'modify', rootTypeid: 'NodeProperty', - escapeLeadingDoubleUnderscore: false + escapeLeadingDoubleUnderscore: false, }); expect(visitedPaths).to.deep.equal(['', 'nested1', 'nested1.nested2', 'nested1.nested2.__doubleUnderscore']); }); @@ -1784,9 +1779,9 @@ describe('Utils', function () { expect(result.propertyChangeSet).to.deep.equal(expectedChangeset); expect(result.insert).to.be.false; }); - });*/ + }); */ - describe('Utils.getFilteredChangeSetByPaths', function () { + describe('Utils.getFilteredChangeSetByPaths', function() { var changeSet = { 'insert': { 'NodeProperty': { @@ -1796,10 +1791,10 @@ describe('Utils', function () { 'nested2': { 'insert': { 'String': { - 'string': 'text' - } - } - } + 'string': 'text', + }, + }, + }, }, 'array<>': { 'nestedArray': { @@ -1808,45 +1803,45 @@ describe('Utils', function () { 0, [ { - 'typeid': 'NodeProperty' + 'typeid': 'NodeProperty', }, { 'typeid': 'NodeProperty', 'insert': { 'String': { - 'text': '' - } - } - } - ] - ] - ] - } + 'text': '', + }, + }, + }, + ], + ], + ], + }, }, 'map<>': { 'trulyNestedMap': { 'insert': { 'String': { - 'key1': 'The value is 1' - } - } - } - } - } + 'key1': 'The value is 1', + }, + }, + }, + }, + }, }, - 'nested3': {} + 'nested3': {}, }, 'map<>': { 'nestedMap': { 'insert': { 'String': { - 'nestedMapString': 'Sirius' + 'nestedMapString': 'Sirius', }, 'Bool': { - 'nestedMapBoolean': true - } - } - } + 'nestedMapBoolean': true, + }, + }, + }, }, 'map': { 'assetMap': { @@ -1854,63 +1849,63 @@ describe('Utils', function () { 'mysample:asset-1.0.0': { '1': { 'String': { - 'name': 'test asset 1' + 'name': 'test asset 1', }, 'NodeProperty': { 'components': { - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, 'Reference': { - 'refProp': '/test.prop' + 'refProp': '/test.prop', }, 'RepositoryReferenceProperty': { 'refRepoProp': { 'Bool': { - 'followBranch': false + 'followBranch': false, }, 'String': { 'branchGUID': '846fe4a1-e595-44bf-8cc0-f1d8f6d104a6', 'commitGUID': '4c611c89-8241-4764-958e-77470bba3b9b', - 'repositoryGUID': 'f438bed5-d8f2-4c70-a7e0-aa52b8929d2a' - } - } + 'repositoryGUID': 'f438bed5-d8f2-4c70-a7e0-aa52b8929d2a', + }, + }, }, 'NamedProperty': { 'namedProp': { 'String': { - 'guid': 'e763527c-7f49-417c-8df3-9fb7f90a1932' - } - } + 'guid': 'e763527c-7f49-417c-8df3-9fb7f90a1932', + }, + }, }, 'NamedNodeProperty': { 'namedNodeProp': { 'String': { - 'guid': 'efc68477-53b1-49ac-bd3f-e05a21f85a32' + 'guid': 'efc68477-53b1-49ac-bd3f-e05a21f85a32', }, 'insert': { 'enum': { - 'enumProp': 0 + 'enumProp': 0, }, 'String': { - 'test': 'blah' - } - } - } + 'test': 'blah', + }, + }, + }, }, 'autodesk.test:testProp-1.0.0': { 'customTemplate': { 'Uint32': { - 'a': 922337203685 + 'a': 922337203685, }, 'String': { 'b': 'hello', 'nested.c.d.e': 'world', - 'nested.c.d.f': 'hello' + 'nested.c.d.f': 'hello', }, 'set': { 'nestedSet': { @@ -1918,42 +1913,42 @@ describe('Utils', function () { 'NamedProperty': { '91a59cb6-9881-2b5f-2366-84dbdc8b6838': { 'String': { - 'guid': '91a59cb6-9881-2b5f-2366-84dbdc8b6838' - } - } - } - } - } - } - } + 'guid': '91a59cb6-9881-2b5f-2366-84dbdc8b6838', + }, + }, + }, + }, + }, + }, + }, }, 'String': { - 'emptyString': '' - } + 'emptyString': '', + }, }, 'modify': { 'NodeProperty': { 'nested4': { 'insert': { 'Uint32': { - 'number': 4 - } + 'number': 4, + }, }, - 'remove': ['nested5', 'nested6'] - } + 'remove': ['nested5', 'nested6'], + }, }, 'array': { 'nestedArray2': { - 'modify': [[0, [0.707, 0.707, 0], [0, 0, 1]]] - } - } + 'modify': [[0, [0.707, 0.707, 0], [0, 0, 1]]], + }, + }, }, 'remove': [ - 'nested7' - ] + 'nested7', + ], }; - it('should filter change sets by paths resolving to all types (NodeProperty, array, map, set, NamedNodeProperty, Reference, Primitive types)', function () { + it('should filter change sets by paths resolving to all types (NodeProperty, array, map, set, NamedNodeProperty, Reference, Primitive types)', function() { var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ['nested1', 'nested4.nested5', 'nested4.number']); expect(filteredCS).to.eql({ 'insert': { @@ -1964,10 +1959,10 @@ describe('Utils', function () { 'nested2': { 'insert': { 'String': { - 'string': 'text' - } - } - } + 'string': 'text', + }, + }, + }, }, 'array<>': { 'nestedArray': { @@ -1976,33 +1971,33 @@ describe('Utils', function () { 0, [ { - 'typeid': 'NodeProperty' + 'typeid': 'NodeProperty', }, { 'typeid': 'NodeProperty', 'insert': { 'String': { - 'text': '' - } - } - } - ] - ] - ] - } + 'text': '', + }, + }, + }, + ], + ], + ], + }, }, 'map<>': { 'trulyNestedMap': { 'insert': { 'String': { - 'key1': 'The value is 1' - } - } - } - } - } - } - } + 'key1': 'The value is 1', + }, + }, + }, + }, + }, + }, + }, }, 'modify': { 'NodeProperty': { @@ -2010,12 +2005,12 @@ describe('Utils', function () { 'remove': ['nested5'], 'insert': { 'Uint32': { - 'number': 4 - } - } - } - } - } + 'number': 4, + }, + }, + }, + }, + }, }); filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ['nested7', 'nested4', 'nested1.nested2']); @@ -2029,30 +2024,30 @@ describe('Utils', function () { 'nested2': { 'insert': { 'String': { - 'string': 'text' - } - } - } - } - } - } - } + 'string': 'text', + }, + }, + }, + }, + }, + }, + }, }, 'modify': { 'NodeProperty': { 'nested4': { 'insert': { 'Uint32': { - 'number': 4 - } + 'number': 4, + }, }, - 'remove': ['nested5', 'nested6'] - } - } + 'remove': ['nested5', 'nested6'], + }, + }, }, 'remove': [ - 'nested7' - ] + 'nested7', + ], }); filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ['nested1.nestedArray', 'nestedMap.nestedMapBoolean', 'nestedArray2']); @@ -2069,41 +2064,41 @@ describe('Utils', function () { 0, [ { - 'typeid': 'NodeProperty' + 'typeid': 'NodeProperty', }, { 'typeid': 'NodeProperty', 'insert': { 'String': { - 'text': '' - } - } - } - ] - ] - ] - } - } - } - } + 'text': '', + }, + }, + }, + ], + ], + ], + }, + }, + }, + }, }, 'map<>': { 'nestedMap': { 'insert': { 'Bool': { - 'nestedMapBoolean': true - } - } - } - } + 'nestedMapBoolean': true, + }, + }, + }, + }, }, 'modify': { 'array': { 'nestedArray2': { - 'modify': [[0, [0.707, 0.707, 0], [0, 0, 1]]] - } - } - } + 'modify': [[0, [0.707, 0.707, 0], [0, 0, 1]]], + }, + }, + }, }); filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ['namedProp.guid', 'namedNodeProp.enumProp', 'namedNodeProp.guid']); @@ -2113,23 +2108,23 @@ describe('Utils', function () { 'NamedProperty': { 'namedProp': { 'String': { - 'guid': 'e763527c-7f49-417c-8df3-9fb7f90a1932' - } - } + 'guid': 'e763527c-7f49-417c-8df3-9fb7f90a1932', + }, + }, }, 'NamedNodeProperty': { 'namedNodeProp': { 'String': { - 'guid': 'efc68477-53b1-49ac-bd3f-e05a21f85a32' + 'guid': 'efc68477-53b1-49ac-bd3f-e05a21f85a32', }, 'insert': { 'enum': { - 'enumProp': 0 - } - } - } - } - } + 'enumProp': 0, + }, + }, + }, + }, + }, }); filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ['customTemplate.a', 'customTemplate.nested.c.d.e', 'customTemplate.nestedSet']); @@ -2139,10 +2134,10 @@ describe('Utils', function () { 'autodesk.test:testProp-1.0.0': { 'customTemplate': { 'Uint32': { - 'a': 922337203685 + 'a': 922337203685, }, 'String': { - 'nested.c.d.e': 'world' + 'nested.c.d.e': 'world', }, 'set': { 'nestedSet': { @@ -2150,16 +2145,16 @@ describe('Utils', function () { 'NamedProperty': { '91a59cb6-9881-2b5f-2366-84dbdc8b6838': { 'String': { - 'guid': '91a59cb6-9881-2b5f-2366-84dbdc8b6838' - } - } - } - } - } - } - } - } - } + 'guid': '91a59cb6-9881-2b5f-2366-84dbdc8b6838', + }, + }, + }, + }, + }, + }, + }, + }, + }, }); filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, new Map([[ @@ -2169,13 +2164,13 @@ describe('Utils', function () { ['nested', new Map([[ 'c', new Map([[ 'd', new Map([[ - 'e', new Map() - ]]) - ]]) + 'e', new Map(), + ]]), + ]]), ]])], - ['nestedSet', new Map()] - ] - ) + ['nestedSet', new Map()], + ], + ), ]])); expect(filteredCS).to.eql({ @@ -2183,10 +2178,10 @@ describe('Utils', function () { 'autodesk.test:testProp-1.0.0': { 'customTemplate': { 'Uint32': { - 'a': 922337203685 + 'a': 922337203685, }, 'String': { - 'nested.c.d.e': 'world' + 'nested.c.d.e': 'world', }, 'set': { 'nestedSet': { @@ -2194,16 +2189,16 @@ describe('Utils', function () { 'NamedProperty': { '91a59cb6-9881-2b5f-2366-84dbdc8b6838': { 'String': { - 'guid': '91a59cb6-9881-2b5f-2366-84dbdc8b6838' - } - } - } - } - } - } - } - } - } + 'guid': '91a59cb6-9881-2b5f-2366-84dbdc8b6838', + }, + }, + }, + }, + }, + }, + }, + }, + }, }); var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ['customTemplate.nested.c']); @@ -2214,11 +2209,11 @@ describe('Utils', function () { 'customTemplate': { 'String': { 'nested.c.d.e': 'world', - 'nested.c.d.f': 'hello' - } - } - } - } + 'nested.c.d.f': 'hello', + }, + }, + }, + }, }); var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ['customTemplate.nested.c.d']); @@ -2229,11 +2224,11 @@ describe('Utils', function () { 'customTemplate': { 'String': { 'nested.c.d.e': 'world', - 'nested.c.d.f': 'hello' - } - } - } - } + 'nested.c.d.f': 'hello', + }, + }, + }, + }, }); filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ['refProp', 'refRepoProp.commitGUID', 'refRepoProp.followBranch']); @@ -2241,19 +2236,19 @@ describe('Utils', function () { expect(filteredCS).to.eql({ 'insert': { 'Reference': { - 'refProp': '/test.prop' + 'refProp': '/test.prop', }, 'RepositoryReferenceProperty': { 'refRepoProp': { 'Bool': { - 'followBranch': false + 'followBranch': false, }, 'String': { - 'commitGUID': '4c611c89-8241-4764-958e-77470bba3b9b' - } - } - } - } + 'commitGUID': '4c611c89-8241-4764-958e-77470bba3b9b', + }, + }, + }, + }, }); filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ['assetMap[1].name']); @@ -2265,14 +2260,14 @@ describe('Utils', function () { 'mysample:asset-1.0.0': { '1': { 'String': { - 'name': 'test asset 1' - } - } - } - } - } - } - } + 'name': 'test asset 1', + }, + }, + }, + }, + }, + }, + }, }); // For maps, using dots as separators, instead of brackets, is also supported. @@ -2285,18 +2280,18 @@ describe('Utils', function () { 'mysample:asset-1.0.0': { '1': { 'String': { - 'name': 'test asset 1' - } - } - } - } - } - } - } + 'name': 'test asset 1', + }, + }, + }, + }, + }, + }, + }, }); }); - it('should ignore overlapping paths', function () { + it('should ignore overlapping paths', function() { var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ['customTemplate', 'customTemplate.a', 'customTemplate.nested.c.d.e', 'customTemplate.nestedSet']); expect(filteredCS).to.eql({ @@ -2304,12 +2299,12 @@ describe('Utils', function () { 'autodesk.test:testProp-1.0.0': { 'customTemplate': { 'Uint32': { - 'a': 922337203685 + 'a': 922337203685, }, 'String': { 'b': 'hello', 'nested.c.d.e': 'world', - 'nested.c.d.f': 'hello' + 'nested.c.d.f': 'hello', }, 'set': { 'nestedSet': { @@ -2317,16 +2312,16 @@ describe('Utils', function () { 'NamedProperty': { '91a59cb6-9881-2b5f-2366-84dbdc8b6838': { 'String': { - 'guid': '91a59cb6-9881-2b5f-2366-84dbdc8b6838' - } - } - } - } - } - } - } - } - } + 'guid': '91a59cb6-9881-2b5f-2366-84dbdc8b6838', + }, + }, + }, + }, + }, + }, + }, + }, + }, }); var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ['customTemplate.nestedSet[91a59cb6-9881-2b5f-2366-84dbdc8b6838].guid']); @@ -2341,16 +2336,16 @@ describe('Utils', function () { 'NamedProperty': { '91a59cb6-9881-2b5f-2366-84dbdc8b6838': { 'String': { - 'guid': '91a59cb6-9881-2b5f-2366-84dbdc8b6838' - } - } - } - } - } - } - } - } - } + 'guid': '91a59cb6-9881-2b5f-2366-84dbdc8b6838', + }, + }, + }, + }, + }, + }, + }, + }, + }, }); // Flip order @@ -2361,12 +2356,12 @@ describe('Utils', function () { 'autodesk.test:testProp-1.0.0': { 'customTemplate': { 'Uint32': { - 'a': 922337203685 + 'a': 922337203685, }, 'String': { 'b': 'hello', 'nested.c.d.e': 'world', - 'nested.c.d.f': 'hello' + 'nested.c.d.f': 'hello', }, 'set': { 'nestedSet': { @@ -2374,16 +2369,16 @@ describe('Utils', function () { 'NamedProperty': { '91a59cb6-9881-2b5f-2366-84dbdc8b6838': { 'String': { - 'guid': '91a59cb6-9881-2b5f-2366-84dbdc8b6838' - } - } - } - } - } - } - } - } - } + 'guid': '91a59cb6-9881-2b5f-2366-84dbdc8b6838', + }, + }, + }, + }, + }, + }, + }, + }, + }, }); // Duplicate paths @@ -2394,12 +2389,12 @@ describe('Utils', function () { 'autodesk.test:testProp-1.0.0': { 'customTemplate': { 'Uint32': { - 'a': 922337203685 + 'a': 922337203685, }, 'String': { 'b': 'hello', 'nested.c.d.e': 'world', - 'nested.c.d.f': 'hello' + 'nested.c.d.f': 'hello', }, 'set': { 'nestedSet': { @@ -2407,16 +2402,16 @@ describe('Utils', function () { 'NamedProperty': { '91a59cb6-9881-2b5f-2366-84dbdc8b6838': { 'String': { - 'guid': '91a59cb6-9881-2b5f-2366-84dbdc8b6838' - } - } - } - } - } - } - } - } - } + 'guid': '91a59cb6-9881-2b5f-2366-84dbdc8b6838', + }, + }, + }, + }, + }, + }, + }, + }, + }, }); var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ['emptyString']); @@ -2424,13 +2419,13 @@ describe('Utils', function () { expect(filteredCS).to.eql({ 'insert': { 'String': { - 'emptyString': '' - } - } + 'emptyString': '', + }, + }, }); }); - it('should return an empty change set when filtering by a path that does not exist', function () { + it('should return an empty change set when filtering by a path that does not exist', function() { var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ['path.that.does.not.exist', 'dontExist', 'does.not.exist']); expect(filteredCS).to.be.eql({}); @@ -2446,30 +2441,30 @@ describe('Utils', function () { 'nested2': { 'insert': { 'String': { - 'string': 'text' - } - } - } - } - } - } - } + 'string': 'text', + }, + }, + }, + }, + }, + }, + }, }, 'modify': { 'NodeProperty': { 'nested4': { 'insert': { 'Uint32': { - 'number': 4 - } + 'number': 4, + }, }, - 'remove': ['nested5', 'nested6'] - } - } + 'remove': ['nested5', 'nested6'], + }, + }, }, 'remove': [ - 'nested7' - ] + 'nested7', + ], }); filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ['nested1.nested2', 'nested1.nested6']); @@ -2483,15 +2478,15 @@ describe('Utils', function () { 'nested2': { 'insert': { 'String': { - 'string': 'text' - } - } - } - } - } - } - } - } + 'string': 'text', + }, + }, + }, + }, + }, + }, + }, + }, }); // Partially matched paths are included @@ -2500,9 +2495,9 @@ describe('Utils', function () { 'insert': { 'map': { 'assetMap': { - } - } - } + }, + }, + }, }); // Closest partially matched path 'customTemplate.nested.c.d' cannot be included @@ -2511,9 +2506,9 @@ describe('Utils', function () { 'insert': { 'autodesk.test:testProp-1.0.0': { 'customTemplate': { - } - } - } + }, + }, + }, }); // Partial match should also work with nested properties @@ -2525,12 +2520,12 @@ describe('Utils', function () { 'insert': { 'map<>': { 'trulyNestedMap': { - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }); // Filter a nested non existing entry from a templated property @@ -2540,26 +2535,25 @@ describe('Utils', function () { 'autodesk.test:testProp-1.0.0': { 'customTemplate': { 'Uint32': { - 'a': 922337203685 + 'a': 922337203685, }, 'set': { 'nestedSet': { - } - } - } - } - } + }, + }, + }, + }, + }, }); // Make sure, nested removes are treated correctly var filteredCS = Utils.getFilteredChangeSetByPaths(changeSet, ['nested7.abcd']); expect(filteredCS).to.eql({ - 'remove': ['nested7'] + 'remove': ['nested7'], }); - }); - it('should fail filtering change sets with paths that resolve into arrays and sets', function () { + it('should fail filtering change sets with paths that resolve into arrays and sets', function() { var failedFilteredFunc = Utils.getFilteredChangeSetByPaths.bind(null, changeSet, ['nested1.nestedArray[0]']); expect(failedFilteredFunc).to.throw(Error, MSG.FILTER_PATH_WITHIN_ARRAY); @@ -2570,7 +2564,7 @@ describe('Utils', function () { expect(failedFilteredFunc).to.throw(Error, MSG.FILTER_PATH_WITHIN_ARRAY); }); - it('should work for ChangeSet with segments requiring escapes for NodeProperties', function () { + it('should work for ChangeSet with segments requiring escapes for NodeProperties', function() { var node = PropertyFactory.create('NodeProperty'); node.insert('."test".', PropertyFactory.create('NodeProperty')); node.get('."test".').insert('[abcd]', PropertyFactory.create('String', undefined, 'test')); @@ -2595,7 +2589,7 @@ describe('Utils', function () { expect(filteredCS).to.deep.equal(CS); }); - it('should work for ChangeSet with segments requiring escapes in template', function () { + it('should work for ChangeSet with segments requiring escapes in template', function() { var node = PropertyFactory.create('autodesk.tests:property.with.quotable.characters-1.0.0'); node.cleanDirty(); @@ -2606,28 +2600,28 @@ describe('Utils', function () { expect(filteredCS).to.deep.equal(CS); }); - it('should work for reversible ChangeSet', function () { + it('should work for reversible ChangeSet', function() { var originalChangeSet = { 'insert': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { - 'F': { 'String': { 'stringProperty': '' } } - } + 'F': { 'String': { 'stringProperty': '' } }, + }, }, 'remove': ['B', 'C'], 'modify': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { - 'A': { 'String': { 'stringProperty': 'hello' } } - } - } + 'A': { 'String': { 'stringProperty': 'hello' } }, + }, + }, }; var parentChangeSet = { 'insert': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { 'A': { 'String': { 'stringProperty': '' } }, 'B': { 'String': { 'stringProperty': '' } }, - 'C': { 'String': { 'stringProperty': '' } } - } - } + 'C': { 'String': { 'stringProperty': '' } }, + }, + }, }; var cs = new ChangeSet(originalChangeSet); @@ -2638,31 +2632,30 @@ describe('Utils', function () { expect(filteredCS).to.eql({ 'insert': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { - 'F': { 'String': { 'stringProperty': '' } } - } + 'F': { 'String': { 'stringProperty': '' } }, + }, }, 'remove': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { - 'B': { 'String': { 'stringProperty': '' } } - } + 'B': { 'String': { 'stringProperty': '' } }, + }, }, 'modify': { 'autodesk.tests:AnonymousMapTestPropertyID-1.0.0': { 'A': { 'String': { 'stringProperty': { 'value': 'hello', - 'oldValue': '' - } - } - } - } - } + 'oldValue': '', + }, + }, + }, + }, + }, }); }); }); describe('Utils.getFilteredOutChangeSetByPaths', () => { - const changeset = { 'insert': { 'map': { @@ -2671,24 +2664,24 @@ describe('Utils', function () { 'autodesk.test:sample-1.0.0': { 'Prop1': { 'String': { - 'guid': 'Prop1' - } + 'guid': 'Prop1', + }, }, 'Prop2': { 'String': { - 'guid': 'Prop2' - } + 'guid': 'Prop2', + }, }, 'Prop3': { 'String': { - 'guid': 'Prop3' - } - } - } - } - } - } - } + 'guid': 'Prop3', + }, + }, + }, + }, + }, + }, + }, }; const singleExclusion = { @@ -2699,19 +2692,19 @@ describe('Utils', function () { 'autodesk.test:sample-1.0.0': { 'Prop1': { 'String': { - 'guid': 'Prop1' - } + 'guid': 'Prop1', + }, }, 'Prop2': { 'String': { - 'guid': 'Prop2' - } - } - } - } - } - } - } + 'guid': 'Prop2', + }, + }, + }, + }, + }, + }, + }, }; const multiExclusion = { @@ -2722,14 +2715,14 @@ describe('Utils', function () { 'autodesk.test:sample-1.0.0': { 'Prop1': { 'String': { - 'guid': 'Prop1' - } - } - } - } - } - } - } + 'guid': 'Prop1', + }, + }, + }, + }, + }, + }, + }, }; it('should exclude single given path', () => { @@ -2765,6 +2758,5 @@ describe('Utils', function () { it('should copy the changeset', () => { expect(Utils.excludePathsFromChangeSet(changeset, ['assets[prop3]'])).to.not.be.equal(changeset); }); - }); }); diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/validation/badMissingSemverInTypeid.js b/experimental/PropertyDDS/packages/property-properties/src/test/validation/badMissingSemverInTypeid.js index 765829428a8c..d56ba9c77bc0 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/validation/badMissingSemverInTypeid.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/validation/badMissingSemverInTypeid.js @@ -19,30 +19,30 @@ var templateSchema = { 'properties': [ { 'id': 'x', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'y', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'z', - 'typeid': 'Float32' - } - ] + 'typeid': 'Float32', + }, + ], }, { 'id': 'color', - 'typeid': 'TeamLeoValidation2:ColorID-1.0.0' + 'typeid': 'TeamLeoValidation2:ColorID-1.0.0', }, { 'id': 'normal', 'typeid': 'Float32', 'context': 'array', - 'length': 3 - } + 'length': 3, + }, ], - 'typeid': 'TeamLeoValidation2:PointID' + 'typeid': 'TeamLeoValidation2:PointID', }; module.exports = templateSchema; diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/validation/badPrimitiveTypeid.js b/experimental/PropertyDDS/packages/property-properties/src/test/validation/badPrimitiveTypeid.js index 04b78e4d1b44..57bfd42f2e27 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/validation/badPrimitiveTypeid.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/validation/badPrimitiveTypeid.js @@ -16,18 +16,18 @@ var templateSchema = { 'properties': [ { 'id': 'r', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'g', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'b', - 'typeid': 'Flob32' - } + 'typeid': 'Flob32', + }, ], - 'typeid': 'TeamLeoValidation2:ColorID-1.0.0' + 'typeid': 'TeamLeoValidation2:ColorID-1.0.0', }; module.exports = templateSchema; diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/validation/goodColorId.js b/experimental/PropertyDDS/packages/property-properties/src/test/validation/goodColorId.js index 4e6d97c783d6..b397bf06d49e 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/validation/goodColorId.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/validation/goodColorId.js @@ -17,20 +17,20 @@ var templateSchema100 = { { 'id': 'r', 'typeid': 'Float32', - 'annotation': { 'description': 'Red' } + 'annotation': { 'description': 'Red' }, }, { 'id': 'g', 'typeid': 'Float32', - 'annotation': { 'description': 'Green' } + 'annotation': { 'description': 'Green' }, }, { 'id': 'b', 'typeid': 'Float32', - 'annotation': { 'description': 'Blue' } - } + 'annotation': { 'description': 'Blue' }, + }, ], - 'typeid': 'TeamLeoValidation2:ColorID-1.0.0' + 'typeid': 'TeamLeoValidation2:ColorID-1.0.0', }; var templateSchema100Modified = { @@ -38,15 +38,15 @@ var templateSchema100Modified = { { 'id': 'r', 'typeid': 'Float32', - 'annotation': { 'description': 'Red' } + 'annotation': { 'description': 'Red' }, }, { 'id': 'g', 'typeid': 'Float32', - 'annotation': { 'description': 'Green' } - } + 'annotation': { 'description': 'Green' }, + }, ], - 'typeid': 'TeamLeoValidation2:ColorID-1.0.0' + 'typeid': 'TeamLeoValidation2:ColorID-1.0.0', }; var templateSchema101 = { @@ -54,21 +54,21 @@ var templateSchema101 = { { 'id': 'r', 'typeid': 'Float32', - 'annotation': { 'description': 'Red' } + 'annotation': { 'description': 'Red' }, }, { 'id': 'g', 'typeid': 'Float32', - 'annotation': { 'description': 'Green' } + 'annotation': { 'description': 'Green' }, }, { 'id': 'b', 'typeid': 'Float32', - 'annotation': { 'description': 'Blue' } - } + 'annotation': { 'description': 'Blue' }, + }, ], 'typeid': 'TeamLeoValidation2:ColorID-1.0.1', - 'annotation': { 'description': 'Color template' } + 'annotation': { 'description': 'Color template' }, }; var templateSchema101BadSemver = { @@ -76,25 +76,25 @@ var templateSchema101BadSemver = { { 'id': 'r', 'typeid': 'Float32', - 'annotation': { 'description': 'Red' } + 'annotation': { 'description': 'Red' }, }, { 'id': 'g', 'typeid': 'Float32', - 'annotation': { 'description': 'Green' } + 'annotation': { 'description': 'Green' }, }, { 'id': 'b', 'typeid': 'Float32', - 'annotation': { 'description': 'Blue' } + 'annotation': { 'description': 'Blue' }, }, { 'id': 'a', 'typeid': 'Float32', - 'annotation': { 'description': 'Alpha' } - } + 'annotation': { 'description': 'Alpha' }, + }, ], - 'typeid': 'TeamLeoValidation2:ColorID-1.0.1' + 'typeid': 'TeamLeoValidation2:ColorID-1.0.1', }; var templateSchema110 = { @@ -102,25 +102,25 @@ var templateSchema110 = { { 'id': 'r', 'typeid': 'Float32', - 'annotation': { 'description': 'Red' } + 'annotation': { 'description': 'Red' }, }, { 'id': 'g', 'typeid': 'Float32', - 'annotation': { 'description': 'Green' } + 'annotation': { 'description': 'Green' }, }, { 'id': 'b', 'typeid': 'Float32', - 'annotation': { 'description': 'Blue' } + 'annotation': { 'description': 'Blue' }, }, { 'id': 'a', 'typeid': 'Float32', - 'annotation': { 'description': 'Alpha' } - } + 'annotation': { 'description': 'Alpha' }, + }, ], - 'typeid': 'TeamLeoValidation2:ColorID-1.1.0' + 'typeid': 'TeamLeoValidation2:ColorID-1.1.0', }; var templateSchema110BadSemver = { @@ -128,15 +128,15 @@ var templateSchema110BadSemver = { { 'id': 'r', 'typeid': 'Float32', - 'annotation': { 'description': 'Red' } + 'annotation': { 'description': 'Red' }, }, { 'id': 'g', 'typeid': 'Float32', - 'annotation': { 'description': 'Green' } - } + 'annotation': { 'description': 'Green' }, + }, ], - 'typeid': 'TeamLeoValidation2:ColorID-1.1.0' + 'typeid': 'TeamLeoValidation2:ColorID-1.1.0', }; var templateSchema110BadSemver2 = { @@ -144,15 +144,15 @@ var templateSchema110BadSemver2 = { { 'id': 'r', 'typeid': 'Float32', - 'annotation': { 'description': 'Red' } + 'annotation': { 'description': 'Red' }, }, { 'id': 'g', 'typeid': 'Float32', - 'annotation': { 'description': 'Green' } - } + 'annotation': { 'description': 'Green' }, + }, ], - 'typeid': 'TeamLeoValidation2:ColorID-1.0.1' + 'typeid': 'TeamLeoValidation2:ColorID-1.0.1', }; var templateSchema200 = { @@ -160,32 +160,32 @@ var templateSchema200 = { { 'id': 'r', 'typeid': 'Float32', - 'annotation': { 'description': 'Red' } + 'annotation': { 'description': 'Red' }, }, { 'id': 'g', 'typeid': 'Float32', - 'annotation': { 'description': 'Green' } - } + 'annotation': { 'description': 'Green' }, + }, ], - 'typeid': 'TeamLeoValidation2:ColorID-2.0.0' + 'typeid': 'TeamLeoValidation2:ColorID-2.0.0', }; const objToExport = { '1-0-0': { original: templateSchema100, - modified: templateSchema100Modified + modified: templateSchema100Modified, }, '1-0-1': { goodSemver: templateSchema101, - badSemver1: templateSchema101BadSemver + badSemver1: templateSchema101BadSemver, }, '1-1-0': { goodSemver: templateSchema110, badSemver1: templateSchema110BadSemver, - badSemver2: templateSchema110BadSemver2 + badSemver2: templateSchema110BadSemver2, }, - '2-0-0': templateSchema200 + '2-0-0': templateSchema200, }; module.exports = objToExport; diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/validation/goodColorPalette.js b/experimental/PropertyDDS/packages/property-properties/src/test/validation/goodColorPalette.js index 4969b128e027..207d54ad22f3 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/validation/goodColorPalette.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/validation/goodColorPalette.js @@ -16,8 +16,8 @@ var templateSchema = { 'typeid': 'Adsk.Library:Colors.ColorPalette-1.0.0', 'properties': [ { 'id': 'colors', 'typeid': 'Reference', 'context': 'map' }, - { 'id': 'testref', 'typeid': 'Reference', 'context': 'map' } - ] + { 'id': 'testref', 'typeid': 'Reference', 'context': 'map' }, + ], }; module.exports = templateSchema; diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/validation/goodPointId.js b/experimental/PropertyDDS/packages/property-properties/src/test/validation/goodPointId.js index f8336f8d6ea6..a3b262514578 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/validation/goodPointId.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/validation/goodPointId.js @@ -19,30 +19,30 @@ var templateSchema = { 'properties': [ { 'id': 'x', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'y', - 'typeid': 'Float32' + 'typeid': 'Float32', }, { 'id': 'z', - 'typeid': 'Float32' - } - ] + 'typeid': 'Float32', + }, + ], }, { 'id': 'color', - 'typeid': 'TeamLeoValidation2:ColorID-1.0.0' + 'typeid': 'TeamLeoValidation2:ColorID-1.0.0', }, { 'id': 'normal', 'typeid': 'Float32', 'context': 'array', - 'length': 3 - } + 'length': 3, + }, ], - 'typeid': 'TeamLeoValidation2:PointID-1.0.0' + 'typeid': 'TeamLeoValidation2:PointID-1.0.0', }; module.exports = templateSchema; diff --git a/experimental/PropertyDDS/packages/property-properties/src/test/validation/reversibleChangeSetTestData.js b/experimental/PropertyDDS/packages/property-properties/src/test/validation/reversibleChangeSetTestData.js index 1ca8ea9c18cb..0d0f0b912b25 100644 --- a/experimental/PropertyDDS/packages/property-properties/src/test/validation/reversibleChangeSetTestData.js +++ b/experimental/PropertyDDS/packages/property-properties/src/test/validation/reversibleChangeSetTestData.js @@ -13,5 +13,5 @@ const originalChangeSet = {"modify":{"autodesk.titanium:vertical-1.0.0":{"fee9d9 module.exports = { parentChangeSet, - originalChangeSet + originalChangeSet, }; diff --git a/experimental/PropertyDDS/packages/property-proxy/package.json b/experimental/PropertyDDS/packages/property-proxy/package.json index b2778c29d238..c169505efc6a 100644 --- a/experimental/PropertyDDS/packages/property-proxy/package.json +++ b/experimental/PropertyDDS/packages/property-proxy/package.json @@ -40,7 +40,7 @@ "@babel/plugin-transform-runtime": "^7.2.0", "@babel/preset-env": "^7.2.0", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", "@typescript-eslint/eslint-plugin": "~5.9.0", diff --git a/experimental/dds/ot/ot/package.json b/experimental/dds/ot/ot/package.json index 4663bf0033dd..68a1527ba7fb 100644 --- a/experimental/dds/ot/ot/package.json +++ b/experimental/dds/ot/ot/package.json @@ -65,7 +65,7 @@ "devDependencies": { "@fluid-internal/test-dds-utils": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/experimental/dds/ot/sharejs/json1/package.json b/experimental/dds/ot/sharejs/json1/package.json index 1639e6938872..f610a67271bd 100644 --- a/experimental/dds/ot/sharejs/json1/package.json +++ b/experimental/dds/ot/sharejs/json1/package.json @@ -67,7 +67,7 @@ "devDependencies": { "@fluid-internal/test-dds-utils": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/experimental/dds/tree/package.json b/experimental/dds/tree/package.json index 31de479ca64a..4da52109de95 100644 --- a/experimental/dds/tree/package.json +++ b/experimental/dds/tree/package.json @@ -48,7 +48,7 @@ "devDependencies": { "@fluidframework/build-common": "^0.23.0", "@fluidframework/container-loader": "^0.58.1000", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/runtime-utils": "^0.58.1000", "@fluidframework/test-drivers": "^0.58.1000", diff --git a/experimental/dds/xtree/package.json b/experimental/dds/xtree/package.json index 41687831b1d8..9b430ee16f74 100644 --- a/experimental/dds/xtree/package.json +++ b/experimental/dds/xtree/package.json @@ -69,7 +69,7 @@ "devDependencies": { "@fluid-internal/test-dds-utils": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/experimental/examples/bubblebench/baseline/package.json b/experimental/examples/bubblebench/baseline/package.json index b86c94b97114..fc448720cbc3 100644 --- a/experimental/examples/bubblebench/baseline/package.json +++ b/experimental/examples/bubblebench/baseline/package.json @@ -50,7 +50,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/experimental/examples/bubblebench/common/package.json b/experimental/examples/bubblebench/common/package.json index c7277c6cdab0..29b8581d1752 100644 --- a/experimental/examples/bubblebench/common/package.json +++ b/experimental/examples/bubblebench/common/package.json @@ -63,7 +63,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", diff --git a/experimental/examples/bubblebench/ot/package.json b/experimental/examples/bubblebench/ot/package.json index bf7b53d5b116..1200cbbe2f7b 100644 --- a/experimental/examples/bubblebench/ot/package.json +++ b/experimental/examples/bubblebench/ot/package.json @@ -52,7 +52,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/experimental/examples/bubblebench/sharedtree/package.json b/experimental/examples/bubblebench/sharedtree/package.json index 9778a4c705c0..bc184abbbd7f 100644 --- a/experimental/examples/bubblebench/sharedtree/package.json +++ b/experimental/examples/bubblebench/sharedtree/package.json @@ -51,7 +51,7 @@ "devDependencies": { "@fluid-tools/webpack-fluid-loader": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/expect-puppeteer": "2.2.1", diff --git a/experimental/framework/data-objects/package.json b/experimental/framework/data-objects/package.json index 3c3caf0c8d8b..6d0832733875 100644 --- a/experimental/framework/data-objects/package.json +++ b/experimental/framework/data-objects/package.json @@ -36,7 +36,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", diff --git a/experimental/framework/get-container/package.json b/experimental/framework/get-container/package.json index d37cec337935..eee28f0f533e 100644 --- a/experimental/framework/get-container/package.json +++ b/experimental/framework/get-container/package.json @@ -41,7 +41,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/experimental/framework/last-edited/package.json b/experimental/framework/last-edited/package.json index f05e094bca18..bae5c6384991 100644 --- a/experimental/framework/last-edited/package.json +++ b/experimental/framework/last-edited/package.json @@ -61,7 +61,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/experimental/framework/react-inputs/package.json b/experimental/framework/react-inputs/package.json index 0406541385af..c982dd1c2463 100644 --- a/experimental/framework/react-inputs/package.json +++ b/experimental/framework/react-inputs/package.json @@ -37,7 +37,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", diff --git a/experimental/framework/react/package.json b/experimental/framework/react/package.json index 3ad4c9c56c76..06b06ef2859e 100644 --- a/experimental/framework/react/package.json +++ b/experimental/framework/react/package.json @@ -40,7 +40,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", diff --git a/lerna-package-lock.json b/lerna-package-lock.json index 5cbd273accb5..62a3148576c6 100644 --- a/lerna-package-lock.json +++ b/lerna-package-lock.json @@ -2088,9 +2088,9 @@ } }, "@types/node": { - "version": "12.20.46", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.46.tgz", - "integrity": "sha512-cPjLXj8d6anFPzFvOPxS3fvly3Shm5nTfl6g8X5smexixbuGUf7hfr21J5tX9JW+UPStp/5P5R8qrKL5IyVJ+A==" + "version": "12.20.47", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.47.tgz", + "integrity": "sha512-BzcaRsnFuznzOItW1WpQrDHM7plAa7GIDMZ6b5pnMbkqEtM/6WCOhvZar39oeMQP79gwvFUWjjptE7/KGcNqFg==" } } }, @@ -2157,9 +2157,9 @@ } }, "@types/node": { - "version": "12.20.46", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.46.tgz", - "integrity": "sha512-cPjLXj8d6anFPzFvOPxS3fvly3Shm5nTfl6g8X5smexixbuGUf7hfr21J5tX9JW+UPStp/5P5R8qrKL5IyVJ+A==" + "version": "12.20.47", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.47.tgz", + "integrity": "sha512-BzcaRsnFuznzOItW1WpQrDHM7plAa7GIDMZ6b5pnMbkqEtM/6WCOhvZar39oeMQP79gwvFUWjjptE7/KGcNqFg==" } } }, @@ -2226,9 +2226,9 @@ } }, "@types/node": { - "version": "12.20.46", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.46.tgz", - "integrity": "sha512-cPjLXj8d6anFPzFvOPxS3fvly3Shm5nTfl6g8X5smexixbuGUf7hfr21J5tX9JW+UPStp/5P5R8qrKL5IyVJ+A==" + "version": "12.20.47", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.47.tgz", + "integrity": "sha512-BzcaRsnFuznzOItW1WpQrDHM7plAa7GIDMZ6b5pnMbkqEtM/6WCOhvZar39oeMQP79gwvFUWjjptE7/KGcNqFg==" } } }, @@ -2532,9 +2532,9 @@ } }, "@types/node": { - "version": "12.20.46", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.46.tgz", - "integrity": "sha512-cPjLXj8d6anFPzFvOPxS3fvly3Shm5nTfl6g8X5smexixbuGUf7hfr21J5tX9JW+UPStp/5P5R8qrKL5IyVJ+A==" + "version": "12.20.47", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.47.tgz", + "integrity": "sha512-BzcaRsnFuznzOItW1WpQrDHM7plAa7GIDMZ6b5pnMbkqEtM/6WCOhvZar39oeMQP79gwvFUWjjptE7/KGcNqFg==" } } }, @@ -2601,9 +2601,9 @@ } }, "@types/node": { - "version": "12.20.46", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.46.tgz", - "integrity": "sha512-cPjLXj8d6anFPzFvOPxS3fvly3Shm5nTfl6g8X5smexixbuGUf7hfr21J5tX9JW+UPStp/5P5R8qrKL5IyVJ+A==" + "version": "12.20.47", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.47.tgz", + "integrity": "sha512-BzcaRsnFuznzOItW1WpQrDHM7plAa7GIDMZ6b5pnMbkqEtM/6WCOhvZar39oeMQP79gwvFUWjjptE7/KGcNqFg==" } } }, @@ -2670,9 +2670,9 @@ } }, "@types/node": { - "version": "12.20.46", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.46.tgz", - "integrity": "sha512-cPjLXj8d6anFPzFvOPxS3fvly3Shm5nTfl6g8X5smexixbuGUf7hfr21J5tX9JW+UPStp/5P5R8qrKL5IyVJ+A==" + "version": "12.20.47", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.47.tgz", + "integrity": "sha512-BzcaRsnFuznzOItW1WpQrDHM7plAa7GIDMZ6b5pnMbkqEtM/6WCOhvZar39oeMQP79gwvFUWjjptE7/KGcNqFg==" } } }, @@ -2933,9 +2933,9 @@ } }, "@fluidframework/eslint-config-fluid": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.26.0.tgz", - "integrity": "sha512-odm+o74yEZU3hFqBag6jPtdLZxv2ponFNGGe/1ZzHw/wVDDDy4G07Kjbai+76t4TH2+dTOWaTjWOFt9h68bU1A==", + "version": "0.27.0-51301", + "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.27.0-51301.tgz", + "integrity": "sha512-P/+BCF8vAwoSBUrkTYizg5iKaRnE0NNEVieur1Lp1HjzvRwKr/UYgVd6EEZ2hZ7SlpB2zMCcGuuccm6uX1A/ow==", "requires": { "@rushstack/eslint-config": "^2.5.1", "@rushstack/eslint-patch": "^1.1.0", @@ -3021,9 +3021,9 @@ } }, "@types/node": { - "version": "12.20.46", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.46.tgz", - "integrity": "sha512-cPjLXj8d6anFPzFvOPxS3fvly3Shm5nTfl6g8X5smexixbuGUf7hfr21J5tX9JW+UPStp/5P5R8qrKL5IyVJ+A==" + "version": "12.20.47", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.47.tgz", + "integrity": "sha512-BzcaRsnFuznzOItW1WpQrDHM7plAa7GIDMZ6b5pnMbkqEtM/6WCOhvZar39oeMQP79gwvFUWjjptE7/KGcNqFg==" } } }, @@ -3076,9 +3076,9 @@ } }, "@types/node": { - "version": "12.20.46", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.46.tgz", - "integrity": "sha512-cPjLXj8d6anFPzFvOPxS3fvly3Shm5nTfl6g8X5smexixbuGUf7hfr21J5tX9JW+UPStp/5P5R8qrKL5IyVJ+A==" + "version": "12.20.47", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.47.tgz", + "integrity": "sha512-BzcaRsnFuznzOItW1WpQrDHM7plAa7GIDMZ6b5pnMbkqEtM/6WCOhvZar39oeMQP79gwvFUWjjptE7/KGcNqFg==" } } }, @@ -3131,9 +3131,9 @@ } }, "@types/node": { - "version": "12.20.46", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.46.tgz", - "integrity": "sha512-cPjLXj8d6anFPzFvOPxS3fvly3Shm5nTfl6g8X5smexixbuGUf7hfr21J5tX9JW+UPStp/5P5R8qrKL5IyVJ+A==" + "version": "12.20.47", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.47.tgz", + "integrity": "sha512-BzcaRsnFuznzOItW1WpQrDHM7plAa7GIDMZ6b5pnMbkqEtM/6WCOhvZar39oeMQP79gwvFUWjjptE7/KGcNqFg==" } } }, @@ -3186,9 +3186,9 @@ } }, "@types/node": { - "version": "12.20.46", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.46.tgz", - "integrity": "sha512-cPjLXj8d6anFPzFvOPxS3fvly3Shm5nTfl6g8X5smexixbuGUf7hfr21J5tX9JW+UPStp/5P5R8qrKL5IyVJ+A==" + "version": "12.20.47", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.47.tgz", + "integrity": "sha512-BzcaRsnFuznzOItW1WpQrDHM7plAa7GIDMZ6b5pnMbkqEtM/6WCOhvZar39oeMQP79gwvFUWjjptE7/KGcNqFg==" } } }, diff --git a/packages/dds/cell/package.json b/packages/dds/cell/package.json index 27b4c63ea763..7d557f52e777 100644 --- a/packages/dds/cell/package.json +++ b/packages/dds/cell/package.json @@ -66,7 +66,7 @@ "devDependencies": { "@fluid-internal/test-dds-utils": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/dds/counter/package.json b/packages/dds/counter/package.json index 0fed44498b2e..1ed10af3cd4e 100644 --- a/packages/dds/counter/package.json +++ b/packages/dds/counter/package.json @@ -63,7 +63,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/dds/ink/package.json b/packages/dds/ink/package.json index fe8881094536..5097ea02fb7f 100644 --- a/packages/dds/ink/package.json +++ b/packages/dds/ink/package.json @@ -66,7 +66,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/dds/map/package.json b/packages/dds/map/package.json index 5b8c32e730ff..b0121c064f45 100644 --- a/packages/dds/map/package.json +++ b/packages/dds/map/package.json @@ -69,7 +69,7 @@ "devDependencies": { "@fluid-internal/test-dds-utils": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/dds/matrix/package.json b/packages/dds/matrix/package.json index 4eb3b7c7218e..58cc8bde4056 100644 --- a/packages/dds/matrix/package.json +++ b/packages/dds/matrix/package.json @@ -71,7 +71,7 @@ "devDependencies": { "@fluid-internal/test-dds-utils": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/dds/matrix/src/permutationvector.ts b/packages/dds/matrix/src/permutationvector.ts index ef11571ea6bc..7f52ccbc2c34 100644 --- a/packages/dds/matrix/src/permutationvector.ts +++ b/packages/dds/matrix/src/permutationvector.ts @@ -282,7 +282,6 @@ export class PermutationVector extends Client { // containing this position and use 'findReconnectionPosition' to adjust for the local ops that // have not yet been submitted. - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion return this.findReconnectionPosition(containingSegment, localSeq) + containingOffset!; } diff --git a/packages/dds/merge-tree/DEV.md b/packages/dds/merge-tree/DEV.md index 9fb7ceb46f60..8cdf8c54f49d 100644 --- a/packages/dds/merge-tree/DEV.md +++ b/packages/dds/merge-tree/DEV.md @@ -8,3 +8,12 @@ Ths distinction is important, as a removed segment with undefined length may not However a not yet visible segment with 0 length may already exist, or will eventually exits on all clients. These have implications for eventually consistent conflict resolution. Generally, we ignore removed segments, and special case invisible segments, like in the case of conflicting insert as handled in the `breakTie` function + +### Zamboni +Zamboni is the garbage collection process in the merge tree. As segment change due to inserts and deletes, we add them to a heap which keeps the segment with the lowest sequence number at the head. These segments drive the zamboni process which is also run on every change. The zamboni process peeks at the heap to determine if the head is below the min sequence, then the segment is eligible. The minimum sequence number is important here, as the minium sequence number is a sequence seen by all clients, and all clients will specify their reference sequence number as above the minium sequence number. This mean that no new operations can come in that reference anything at or below the minimum sequence number, so we are safe to clean up anything we would need to applying incoming. Eligible segments are collected, and then a few different operations are done, superficially, merge, remove, and tree rebalance. Zamboni is incremental, and only collects a constant number of segments at each change so as not to introduce performance issues. + +Merge is done if two adjacent segments are of the same type like text, that type is mergable (markers are not), neither are deleted, and all the properties match. The merge process reduces the number of segments, which are leaf nodes of the merge tree. For instance a user may type `c`, `a`, and `t` with each character being it's own operation therefore segment. The user could then highlight that range, and set a property on on all the characters indicating that they are bold, `{bold: true}`. At some later point, these segments would move to the top of th heap, and their sequence numbers would move below the minium sequence number. At that point zamboni could take those individual segments, and merge the into a single segment, `cat` with the property `{bold: true}` + +Remove is a bit simpler. On removal of a segment, we track it's removed sequence number. When the segment's removed sequence number drops below the minimum sequence number it can be safely removed from the tree. + +Rebalance is a bit different from merge and remove, as it has to do with maintaining the tree itself. After merge or removal there are fewer segments aka leaf nodes in the tree. This allows us to more efficiently pack the non-leaf node of the tree, and potentially remove layers from the tree. This keeps the tree compact, which has both memory, and cpu performance implications. diff --git a/packages/dds/merge-tree/package.json b/packages/dds/merge-tree/package.json index 08b5ee5dc83a..906418003d99 100644 --- a/packages/dds/merge-tree/package.json +++ b/packages/dds/merge-tree/package.json @@ -67,7 +67,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/dds/merge-tree/src/base.ts b/packages/dds/merge-tree/src/base.ts index a0a011dcaad6..c9341d366f40 100644 --- a/packages/dds/merge-tree/src/base.ts +++ b/packages/dds/merge-tree/src/base.ts @@ -14,7 +14,7 @@ export interface QProperty { } export interface PropertyAction { - + // eslint-disable-next-line @typescript-eslint/prefer-function-type (p: Property, accum?: TAccum): boolean; } @@ -35,7 +35,7 @@ export interface SortedDictionary extends Dictionary { } export interface KeyComparer { - + // eslint-disable-next-line @typescript-eslint/prefer-function-type (a: TKey, b: TKey): number; } /** diff --git a/packages/dds/merge-tree/src/mergeTree.ts b/packages/dds/merge-tree/src/mergeTree.ts index 772ef28f5058..b523f38750ae 100644 --- a/packages/dds/merge-tree/src/mergeTree.ts +++ b/packages/dds/merge-tree/src/mergeTree.ts @@ -107,13 +107,12 @@ export interface IRemovalInfo { removedSeq: number; removedClientIds: number[]; } -export function toRemovalInfo(maybe: Partial | undefined): IRemovalInfo | undefined{ - - if(maybe?.removedClientIds !== undefined && maybe?.removedSeq !== undefined ){ +export function toRemovalInfo(maybe: Partial | undefined): IRemovalInfo | undefined { + if (maybe?.removedClientIds !== undefined && maybe?.removedSeq !== undefined) { return maybe as IRemovalInfo; } assert(maybe?.removedClientIds === undefined && maybe?.removedSeq === undefined, - "both removedClientIds and removedSeq should be set or not set") + "both removedClientIds and removedSeq should be set or not set"); } /** @@ -156,12 +155,12 @@ export interface ISegment extends IMergeNodeCommon, Partial { } export interface IMarkerModifiedAction { - + // eslint-disable-next-line @typescript-eslint/prefer-function-type (marker: Marker): void; } export interface ISegmentAction { - + // eslint-disable-next-line @typescript-eslint/prefer-function-type (segment: ISegment, pos: number, refSeq: number, clientId: number, start: number, end: number, accum: TClientData): boolean; } @@ -172,7 +171,7 @@ export interface ISegmentChanges { } export interface BlockAction { - + // eslint-disable-next-line @typescript-eslint/prefer-function-type ( block: IMergeBlock, pos: number, @@ -185,7 +184,7 @@ export interface BlockAction { } export interface NodeAction { - + // eslint-disable-next-line @typescript-eslint/prefer-function-type ( node: IMergeNode, pos: number, @@ -265,7 +264,6 @@ export class MergeNode implements IMergeNodeCommon { } } - function addTile(tile: ReferencePosition, tiles: object) { const tileLabels = tile.getTileLabels(); if (tileLabels) { @@ -275,7 +273,6 @@ function addTile(tile: ReferencePosition, tiles: object) { } } - function addTileIfNotPresent(tile: ReferencePosition, tiles: object) { const tileLabels = tile.getTileLabels(); if (tileLabels) { @@ -288,7 +285,7 @@ function addTileIfNotPresent(tile: ReferencePosition, tiles: object) { } function applyStackDelta(currentStackMap: RangeStackMap, deltaStackMap: RangeStackMap) { - // eslint-disable-next-line guard-for-in + // eslint-disable-next-line guard-for-in, no-restricted-syntax for (const label in deltaStackMap) { const deltaStack = deltaStackMap[label]; if (!deltaStack.empty()) { @@ -466,7 +463,7 @@ class HierMergeBlock extends MergeBlock implements IMergeBlock { public hierToString(indentCount: number) { let strbuf = ""; - // eslint-disable-next-line guard-for-in + // eslint-disable-next-line guard-for-in, no-restricted-syntax for (const key in this.rangeStacks) { const stack = this.rangeStacks[key]; strbuf += internedSpaces(indentCount); @@ -529,7 +526,7 @@ export abstract class BaseSegment extends MergeNode implements ISegment { b.clientId = this.clientId; // TODO: deep clone properties b.properties = clone(this.properties); - b.removedClientIds = this.removedClientIds?.slice() + b.removedClientIds = this.removedClientIds?.slice(); // TODO: copy removed client overlap and branch removal info b.removedSeq = this.removedSeq; b.seq = this.seq; @@ -814,6 +811,7 @@ export class Marker extends BaseSegment implements ReferencePosition { // (Substitute a debug string instead.) const handle = !!value && value.IFluidHandle; + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return handle ? `#Handle(${handle.routeContext.path}/${handle.path})` : value; @@ -1157,6 +1155,7 @@ export class MergeTree { this.blockUpdate(block); } + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return blocks.length === 1 // If there is only one block at this layer... ? blocks[0] // ...then we're done. Return the root. : buildMergeBlock(blocks); // ...otherwise recursively build the next layer above blocks. @@ -1346,9 +1345,7 @@ export class MergeTree { } if (this.underflow(block) && block.parent) { - this.packParent(block.parent); - } else { this.nodeUpdateOrdinals(block); this.blockUpdatePathLengths(block, UnassignedSequenceNumber, -1, true); @@ -1385,8 +1382,8 @@ export class MergeTree { stats.leafCount += childStats.leafCount; stats.removedLeafCount += childStats.removedLeafCount; stats.liveCount += childStats.liveCount; - for (let i = 0; i < MaxNodesInBlock; i++) { - stats.histo[i] += childStats.histo[i]; + for (let j = 0; j < MaxNodesInBlock; j++) { + stats.histo[j] += childStats.histo[j]; } } else { stats.leafCount++; @@ -1440,7 +1437,7 @@ export class MergeTree { let segment: T | undefined; let offset: number | undefined; - const leaf = (leafSeg: ISegment, segpos: number, refSeq: number, clientId: number, start: number) => { + const leaf = (leafSeg: ISegment, segpos: number, _refSeq: number, _clientId: number, start: number) => { segment = leafSeg as T; offset = start; return false; @@ -1952,8 +1949,7 @@ export class MergeTree { remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: number): number | undefined { - - if(remoteClientRefSeq < this.collabWindow.minSeq){ + if(remoteClientRefSeq < this.collabWindow.minSeq) { return undefined; } @@ -1996,7 +1992,7 @@ export class MergeTree { newSegments: T[], ) { let segIsLocal = false; - const checkSegmentIsLocal = (segment: ISegment, pos: number, refSeq: number, clientId: number) => { + const checkSegmentIsLocal = (segment: ISegment, _pos: number, _refSeq: number, _clientId: number) => { if (segment.seq === UnassignedSequenceNumber) { segIsLocal = true; } @@ -2027,7 +2023,7 @@ export class MergeTree { } } }; - const onLeaf = (segment: ISegment | undefined, pos: number, context: InsertContext) => { + const onLeaf = (segment: ISegment | undefined, _pos: number, context: InsertContext) => { const segmentChanges: ISegmentChanges = {}; if (segment) { // Insert before segment @@ -2122,23 +2118,23 @@ export class MergeTree { while (parent) { const children = parent.children; let childIndex: number; - let node: IMergeNode; + let _node: IMergeNode; let matchedStart = false; for (childIndex = parent.childCount - 1; childIndex >= 0; childIndex--) { - node = children[childIndex]; + _node = children[childIndex]; if (matchedStart) { - if (!node.isLeaf()) { - const childBlock = node; + if (!_node.isLeaf()) { + const childBlock = _node; go = this.nodeMapReverse(childBlock, leafAction, 0, UniversalSequenceNumber, this.collabWindow.clientId); } else { - go = leafAction(node, 0, UniversalSequenceNumber, this.collabWindow.clientId, 0, 0, undefined); + go = leafAction(_node, 0, UniversalSequenceNumber, this.collabWindow.clientId, 0, 0, undefined); } if (!go) { return; } } else { - matchedStart = (startNode === node); + matchedStart = (startNode === _node); } } startNode = parent; @@ -2155,23 +2151,23 @@ export class MergeTree { while (parent) { const children = parent.children; let childIndex: number; - let node: IMergeNode; + let _node: IMergeNode; let matchedStart = false; for (childIndex = 0; childIndex < parent.childCount; childIndex++) { - node = children[childIndex]; + _node = children[childIndex]; if (matchedStart) { - if (!node.isLeaf()) { - const childBlock = node; + if (!_node.isLeaf()) { + const childBlock = _node; go = this.nodeMap(childBlock, actions, 0, UniversalSequenceNumber, this.collabWindow.clientId, undefined); } else { - go = leafAction(node, 0, UniversalSequenceNumber, this.collabWindow.clientId, 0, 0, undefined); + go = leafAction(_node, 0, UniversalSequenceNumber, this.collabWindow.clientId, 0, 0, undefined); } if (!go) { return; } } else { - matchedStart = (startNode === node); + matchedStart = (startNode === _node); } } startNode = parent; @@ -2375,7 +2371,7 @@ export class MergeTree { const removedSegments: IMergeTreeSegmentDelta[] = []; const savedLocalRefs: LocalReferenceCollection[] = []; const localSeq = seq === UnassignedSequenceNumber ? ++this.collabWindow.localSeq : undefined; - const markRemoved = (segment: ISegment, pos: number, start: number, end: number) => { + const markRemoved = (segment: ISegment, pos: number, _start: number, _end: number) => { const existingRemovalInfo = toRemovalInfo(segment); if (existingRemovalInfo !== undefined) { _overwrite = true; @@ -2415,7 +2411,7 @@ export class MergeTree { } return true; }; - const afterMarkRemoved = (node: IMergeBlock, pos: number, start: number, end: number) => { + const afterMarkRemoved = (node: IMergeBlock, pos: number, _start: number, _end: number) => { if (_overwrite) { this.nodeUpdateLengthNewStructure(node); } else { diff --git a/packages/dds/merge-tree/src/mergeTreeDeltaCallback.ts b/packages/dds/merge-tree/src/mergeTreeDeltaCallback.ts index 1587306503b0..4452d81ada06 100644 --- a/packages/dds/merge-tree/src/mergeTreeDeltaCallback.ts +++ b/packages/dds/merge-tree/src/mergeTreeDeltaCallback.ts @@ -75,6 +75,7 @@ export interface IMergeTreeClientSequenceArgs { export type MergeTreeDeltaCallback = (opArgs: IMergeTreeDeltaOpArgs, deltaArgs: IMergeTreeDeltaCallbackArgs) => void; +// eslint-disable-next-line @typescript-eslint/no-empty-interface export interface IMergeTreeMaintenanceCallbackArgs extends IMergeTreeDeltaCallbackArgs { } export type MergeTreeMaintenanceCallback = diff --git a/packages/dds/merge-tree/src/partialLengths.ts b/packages/dds/merge-tree/src/partialLengths.ts index b38aa4ce9415..7ec6615d6d48 100644 --- a/packages/dds/merge-tree/src/partialLengths.ts +++ b/packages/dds/merge-tree/src/partialLengths.ts @@ -187,7 +187,6 @@ export class PartialSequenceLengths { } } if (outerIndexOfEarliest >= 0) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion addNext(earliestPartialLength!); indices[outerIndexOfEarliest]++; @@ -367,7 +366,6 @@ export class PartialSequenceLengths { } } if (seqPartialLen === undefined) { - seqPartialLen = { clientId, seglen: seqSeglen, @@ -488,7 +486,7 @@ export class PartialSequenceLengths { buf += `(${partial.seq},${partial.len}) `; } - // eslint-disable-next-line @typescript-eslint/no-for-in-array + // eslint-disable-next-line @typescript-eslint/no-for-in-array, no-restricted-syntax for (const clientId in this.clientSeqNumbers) { if (this.clientSeqNumbers[clientId].length > 0) { buf += `Client `; @@ -530,7 +528,7 @@ export class PartialSequenceLengths { return minLength; } this.minLength += copyDown(this.partialLengths); - // eslint-disable-next-line @typescript-eslint/no-for-in-array, guard-for-in + // eslint-disable-next-line @typescript-eslint/no-for-in-array, guard-for-in, no-restricted-syntax for (const clientId in this.clientSeqNumbers) { const cliPartials = this.clientSeqNumbers[clientId]; if (cliPartials) { diff --git a/packages/dds/merge-tree/src/properties.ts b/packages/dds/merge-tree/src/properties.ts index a2ba7ab110d1..a60ab7599858 100644 --- a/packages/dds/merge-tree/src/properties.ts +++ b/packages/dds/merge-tree/src/properties.ts @@ -55,8 +55,11 @@ export function combine(combiningInfo: ICombiningOp, currentValue: any, newValue } } break; + default: + break; } + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return _currentValue; } @@ -67,6 +70,7 @@ export function matchProperties(a: PropertySet | undefined, b: PropertySet | und } else { // For now, straightforward; later use hashing + // eslint-disable-next-line no-restricted-syntax for (const key in a) { if (b[key] === undefined) { return false; @@ -79,6 +83,7 @@ export function matchProperties(a: PropertySet | undefined, b: PropertySet | und } } + // eslint-disable-next-line no-restricted-syntax for (const key in b) { if (a[key] === undefined) { return false; @@ -100,10 +105,11 @@ export function extend( seq?: number, ) { if (extension !== undefined) { - // eslint-disable-next-line guard-for-in + // eslint-disable-next-line guard-for-in, no-restricted-syntax for (const key in extension) { const v = extension[key]; if (v === null) { + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete delete base[key]; } else { if (combiningOp && (combiningOp.name !== "rewrite")) { @@ -122,7 +128,7 @@ export function clone(extension: MapLike | undefined) { return undefined; } const cloneMap = createMap(); - // eslint-disable-next-line guard-for-in + // eslint-disable-next-line guard-for-in, no-restricted-syntax for (const key in extension) { const v = extension[key]; if (v !== null) { @@ -148,7 +154,7 @@ export function addProperties( export function extendIfUndefined(base: MapLike, extension: MapLike | undefined) { if (extension !== undefined) { - + // eslint-disable-next-line no-restricted-syntax for (const key in extension) { if (base[key] === undefined) { base[key] = extension[key]; diff --git a/packages/dds/merge-tree/src/segmentPropertiesManager.ts b/packages/dds/merge-tree/src/segmentPropertiesManager.ts index 8fc94e3a1a4d..fcc0db8ed55b 100644 --- a/packages/dds/merge-tree/src/segmentPropertiesManager.ts +++ b/packages/dds/merge-tree/src/segmentPropertiesManager.ts @@ -33,7 +33,7 @@ export class PropertiesManager { 0x05c /* "Trying to update more annotate props than do exist!" */); this.pendingKeyUpdateCount[key]--; if (this.pendingKeyUpdateCount?.[key] === 0) { - + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete delete this.pendingKeyUpdateCount[key]; } } @@ -78,6 +78,7 @@ export class PropertiesManager { if (!newProps[key] && shouldModifyKey(key)) { deltas[key] = oldProps[key]; + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete delete oldProps[key]; } } @@ -105,7 +106,7 @@ export class PropertiesManager { newValue = newProps[key]; } if (newValue === null) { - + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete delete oldProps[key]; } else { oldProps[key] = newValue; @@ -122,7 +123,7 @@ export class PropertiesManager { ): PropertySet | undefined { if (oldProps) { if (!newProps) { - + // eslint-disable-next-line no-param-reassign newProps = createMap(); } if (!newManager) { diff --git a/packages/dds/merge-tree/src/snapshotChunks.ts b/packages/dds/merge-tree/src/snapshotChunks.ts index be68b3fde488..b9585744559f 100644 --- a/packages/dds/merge-tree/src/snapshotChunks.ts +++ b/packages/dds/merge-tree/src/snapshotChunks.ts @@ -66,7 +66,7 @@ export interface IJSONSegmentWithMergeInfo { * @deprecated - use removedClientIds instead. this only exists for back-compat */ removedClient?: string; - removedClientIds?:string[]; + removedClientIds?: string[]; removedSeq?: number; } diff --git a/packages/dds/merge-tree/src/snapshotLoader.ts b/packages/dds/merge-tree/src/snapshotLoader.ts index 9f30cb44e593..9b3ee83e6b31 100644 --- a/packages/dds/merge-tree/src/snapshotLoader.ts +++ b/packages/dds/merge-tree/src/snapshotLoader.ts @@ -105,9 +105,9 @@ export class SnapshotLoader { // this format had a bug where it didn't store all the overlap clients // this is for back compat, so we change the singular id to an array // this will only cause problems if there is an overlapping delete - //spanning the snapshot, which should be rare + // spanning the snapshot, which should be rare if (spec.removedClient !== undefined) { - seg.removedClientIds = [this.client.getOrAddShortClientId(spec.removedClient)] + seg.removedClientIds = [this.client.getOrAddShortClientId(spec.removedClient)]; } if (spec.removedClientIds !== undefined) { seg.removedClientIds = spec.removedClientIds?.map( diff --git a/packages/dds/merge-tree/src/test/beastTest.ts b/packages/dds/merge-tree/src/test/beastTest.ts index 709a629d9d6f..7c7f40985786 100644 --- a/packages/dds/merge-tree/src/test/beastTest.ts +++ b/packages/dds/merge-tree/src/test/beastTest.ts @@ -745,8 +745,8 @@ export function TestPack(verbose = true) { client.applyMessages(countToApply); } - function serverProcessSome(server: TestClient, all = false) { - const svrMsgCount = server.getMessageCount(); + function serverProcessSome(_server: TestClient, all = false) { + const svrMsgCount = _server.getMessageCount(); let countToApply: number; if (all) { countToApply = svrMsgCount; @@ -754,7 +754,7 @@ export function TestPack(verbose = true) { else { countToApply = random.integer(Math.floor(2 * svrMsgCount / 3), svrMsgCount)(mt); } - return server.applyMessages(countToApply); + return _server.applyMessages(countToApply); } function randomSpateOfInserts(client: TestClient, charIndex: number) { @@ -1399,21 +1399,21 @@ function tst() { let corpusFilename = path.join(__dirname, "../../../public/literature/pp.txt"); let corpusContent = fs.readFileSync(corpusFilename, "utf8"); const corpusTree = new TST(); - function addCorpus(corpusContent: string, corpusTree: TST) { + function addCorpus(_corpusContent: string, _corpusTree: TST) { let count = 0; const re = /\b\w+\b/g; let result: RegExpExecArray; do { - result = re.exec(corpusContent); + result = re.exec(_corpusContent); if (result) { const candidate = result[0]; count++; - const val = corpusTree.get(candidate); + const val = _corpusTree.get(candidate); if (val !== undefined) { - corpusTree.put(candidate, val + 1); + _corpusTree.put(candidate, val + 1); } else { - corpusTree.put(candidate, 1); + _corpusTree.put(candidate, 1); } } } while (result); @@ -1517,7 +1517,7 @@ export class DocumentTree { ); this.pos++; } else { - + // eslint-disable-next-line @typescript-eslint/restrict-plus-operands const trid = docNode.name + this.ids[docNode.name].toString(); docNode.id = trid; id = this.ids[docNode.name]++; @@ -1560,7 +1560,7 @@ export class DocumentTree { }; function printStack(stack: Stack) { - // eslint-disable-next-line @typescript-eslint/no-for-in-array, guard-for-in + // eslint-disable-next-line @typescript-eslint/no-for-in-array, guard-for-in, no-restricted-syntax for (const item in stack.items) { log(item); } diff --git a/packages/dds/merge-tree/src/test/client.applyMsg.spec.ts b/packages/dds/merge-tree/src/test/client.applyMsg.spec.ts index 09fb3c075074..b3ae32cf23ae 100644 --- a/packages/dds/merge-tree/src/test/client.applyMsg.spec.ts +++ b/packages/dds/merge-tree/src/test/client.applyMsg.spec.ts @@ -234,7 +234,7 @@ describe("client.applyMsg", () => { const remoteClient = new TestClient(); remoteClient.insertTextLocal(0, client.getText()); remoteClient.startOrUpdateCollaboration("remoteUser"); - const clients = [client, remoteClient] + const clients = [client, remoteClient]; const logger = new TestClientLogger(clients); let seq = 0; const initialMsg = client.makeOpMessage(client.insertTextLocal(0, "-"), ++seq); @@ -399,7 +399,6 @@ describe("client.applyMsg", () => { while (messages.length > 0) { const msg = messages.shift(); clients.forEach((c)=>c.applyMsg(msg)); - } logger.validate(); }); diff --git a/packages/dds/merge-tree/src/test/client.localReferenceFarm.spec.ts b/packages/dds/merge-tree/src/test/client.localReferenceFarm.spec.ts new file mode 100644 index 000000000000..5b06e8fe37f9 --- /dev/null +++ b/packages/dds/merge-tree/src/test/client.localReferenceFarm.spec.ts @@ -0,0 +1,112 @@ +/*! + * Copyright (c) Microsoft Corporation and contributors. All rights reserved. + * Licensed under the MIT License. + */ + +import { strict as assert } from "assert"; +import random from "random-js"; +import { LocalReference, ReferenceType } from ".."; +import { + IMergeTreeOperationRunnerConfig, + removeRange, + runMergeTreeOperationRunner, + generateClientNames, + IConfigRange, +} from "./mergeTreeOperationRunner"; +import { TestClient } from "./testClient"; +import { TestClientLogger } from "./testClientLogger"; +import { doOverRange } from "."; + + const defaultOptions: Record<"initLen" | "modLen", IConfigRange> & IMergeTreeOperationRunnerConfig = { + initLen: {min: 2, max: 4}, + modLen: {min: 1, max: 8}, + opsPerRoundRange: {min: 10, max: 10}, + rounds: 10, + operations: [removeRange], + growthFunc: (input: number) => input * 2, +}; + +describe("MergeTree.Client", () => { + // Generate a list of single character client names, support up to 69 clients + const clientNames = generateClientNames(); + + doOverRange(defaultOptions.initLen, defaultOptions.growthFunc, (initLen)=>{ + doOverRange(defaultOptions.modLen, defaultOptions.growthFunc, (modLen)=>{ + it(`LocalReferenceFarm_${initLen}_${modLen}`, async () => { + const mt = random.engines.mt19937(); + mt.seedWithArray([0xDEADBEEF, 0xFEEDBED, initLen, modLen]); + + const clients: TestClient[] = new Array(3).fill(0).map(()=> new TestClient()); + clients.forEach( + (c, i) => c.startOrUpdateCollaboration(clientNames[i])); + + let seq = 0; + // init with random values + seq = runMergeTreeOperationRunner( + mt, + seq, + clients, + initLen, + defaultOptions, + ); + // add local references + const refs: LocalReference[][] = []; + + const validateRefs = (reason: string, workload: () => void)=>{ + const preWorkload = TestClientLogger.toString(clients); + workload(); + for(let c = 1; c < clients.length; c++) { + for(let r = 0; r < refs[c].length; r++) { + const pos0 = refs[0][r].toPosition(); + const posC = refs[c][r].toPosition(); + if(pos0 !== posC) { + assert.equal( + pos0, posC, + `${reason}:\n${preWorkload}\n${TestClientLogger.toString(clients)}`); + } + } + } + // console.log(`${reason}:\n${preWorkload}\n${TestClientLogger.toString(clients)}`) + }; + + validateRefs("Initialize", ()=>{ + clients.forEach((c,i)=>{ + refs.push([]); + for(let t = 0; t < c.getLength(); t++) { + const seg = c.getContainingSegment(t); + const lref = new LocalReference(c, seg.segment, seg.offset, ReferenceType.SlideOnRemove); + c.addLocalReference(lref); + lref.addProperties({t}); + refs[i].push(lref); + } + }); + }); + + validateRefs("After Init Zamboni",()=>{ + // trigger zamboni multiple times as it is incremental + for(let i = clients[0].getCollabWindow().minSeq; i <= seq; i++) { + clients.forEach((c)=>c.updateMinSeq(i)); + } + }); + + validateRefs("After More Ops", ()=>{ + // init with random values + seq = runMergeTreeOperationRunner( + mt, + seq, + clients, + modLen, + defaultOptions, + ); + }); + + validateRefs("After Final Zamboni",()=>{ + // trigger zamboni multiple times as it is incremental + for(let i = clients[0].getCollabWindow().minSeq; i <= seq; i++) { + clients.forEach((c)=>c.updateMinSeq(i)); + } + }); + }); + }); + }); +}); diff --git a/packages/dds/merge-tree/src/test/mergeTreeOperationRunner.ts b/packages/dds/merge-tree/src/test/mergeTreeOperationRunner.ts index 18a879cb5965..5a8e76aa1b62 100644 --- a/packages/dds/merge-tree/src/test/mergeTreeOperationRunner.ts +++ b/packages/dds/merge-tree/src/test/mergeTreeOperationRunner.ts @@ -192,6 +192,7 @@ export function generateClientNames(): string[] { addClientNames("A", 26); addClientNames("a", 26); addClientNames("0", 17); + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return clientNames; } @@ -209,11 +210,11 @@ export function applyMessages( message.sequenceNumber = ++seq; clients.forEach((c) => c.applyMsg(message)); } - }catch(e){ - if(e instanceof Error){ + } catch(e) { + if(e instanceof Error) { e.message += `\n${logger.toString()}`; } - if(typeof e === "string"){ + if(typeof e === "string") { throw new Error(`${e}\n${logger.toString()}`); } throw e; diff --git a/packages/dds/merge-tree/src/test/testClientLogger.ts b/packages/dds/merge-tree/src/test/testClientLogger.ts index 00f510f31dc1..48a207070c4d 100644 --- a/packages/dds/merge-tree/src/test/testClientLogger.ts +++ b/packages/dds/merge-tree/src/test/testClientLogger.ts @@ -5,14 +5,14 @@ import { strict as assert } from "assert"; import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions"; +import { IMergeTreeDeltaOpArgs, MergeTreeMaintenanceType } from ".."; import { UnassignedSequenceNumber } from "../constants"; import { IMergeTreeOp } from "../ops"; import { TextSegment } from "../textSegment"; import { TestClient } from "./testClient"; -import { IMergeTreeDeltaOpArgs, MergeTreeMaintenanceType } from ".."; -function getOpString(msg: ISequencedDocumentMessage | undefined){ - if(msg === undefined){ +function getOpString(msg: ISequencedDocumentMessage | undefined) { + if(msg === undefined) { return ""; } const op = msg.contents as IMergeTreeOp; @@ -20,13 +20,13 @@ function getOpString(msg: ISequencedDocumentMessage | undefined){ // eslint-disable-next-line @typescript-eslint/dot-notation, max-len const opPos = op && op["pos1"] !== undefined ? `@${op["pos1"]}${op["pos2"] !== undefined ? `,${op["pos2"]}` : ""}` : ""; - const seq = msg.sequenceNumber < 0 ? "L" : (msg.sequenceNumber - msg.minimumSequenceNumber).toString() + const seq = msg.sequenceNumber < 0 ? "L" : (msg.sequenceNumber - msg.minimumSequenceNumber).toString(); const ref = (msg.referenceSequenceNumber - msg.minimumSequenceNumber).toString(); - const client = msg.clientId + const client = msg.clientId; return `${seq}:${ref}:${client}${opType}${opPos}`; } -type ClientMap = Partial> +type ClientMap = Partial>; export function createClientsAtInitialState( initialState: string, @@ -35,18 +35,18 @@ export function createClientsAtInitialState( { const setup = (c: TestClient)=>{ c.insertTextLocal(0, initialState); - while(c.getText().includes("-")){ + while(c.getText().includes("-")) { const index = c.getText().indexOf("-"); - c.removeRangeLocal(index, index +1); + c.removeRangeLocal(index, index + 1); } - } - const all: TestClient[]=[]; - const clients: Partial> ={}; - for(const id of clientIds){ - if(clients[id] === undefined){ - clients[id]= new TestClient(); + }; + const all: TestClient[] = []; + const clients: Partial> = {}; + for(const id of clientIds) { + if(clients[id] === undefined) { + clients[id] = new TestClient(); all.push(clients[id]); - setup(clients[id]) + setup(clients[id]); clients[id].startOrUpdateCollaboration(id); } } @@ -54,6 +54,14 @@ export function createClientsAtInitialState( return {...clients, all}; } export class TestClientLogger { + public static toString(clients: readonly TestClient[]) { + return clients.map((c)=>this.getSegString(c)).reduce<[string,string]>((pv,cv)=>{ + pv[0] += `|${cv.acked.padEnd(cv.local.length,"")}`; + pv[1] += `|${cv.local.padEnd(cv.acked.length,"")}`; + return pv; + },["",""]).join("\n"); + } + private readonly incrementalLog = false; private readonly paddings: number[] = []; @@ -62,27 +70,27 @@ export class TestClientLogger { private ackedLine: string[]; private localLine: string[]; // initialize to private instance, so first real edit will create a new line - private lastOp: any | undefined ={}; + private lastOp: any | undefined = {}; constructor( private readonly clients: readonly TestClient[], - private readonly title?: string) { - + private readonly title?: string, + ) { const logHeaders = []; clients.forEach((c,i)=>{ - logHeaders.push("op") - logHeaders.push( `client ${c.longClientId}`); + logHeaders.push("op"); + logHeaders.push(`client ${c.longClientId}`); const callback = (op: IMergeTreeDeltaOpArgs)=>{ - if(this.lastOp !== op.op){ + if(this.lastOp !== op.op) { this.addNewLogLine(); this.lastOp = op.op; } - const clientLogIndex = i*2 + const clientLogIndex = i * 2; - this.ackedLine[clientLogIndex]=getOpString(op.sequencedMessage ?? c.makeOpMessage(op.op)) - const segStrings = this.getSegString(c); + this.ackedLine[clientLogIndex] = getOpString(op.sequencedMessage ?? c.makeOpMessage(op.op)); + const segStrings = TestClientLogger.getSegString(c); this.ackedLine[clientLogIndex + 1] = segStrings.acked; - this.localLine[clientLogIndex +1] = segStrings.local; + this.localLine[clientLogIndex + 1] = segStrings.local; this.paddings[clientLogIndex] = Math.max( @@ -95,13 +103,13 @@ export class TestClientLogger { this.ackedLine[clientLogIndex + 1].length, this.localLine[clientLogIndex + 1].length, this.paddings[clientLogIndex + 1]); - } + }; c.mergeTreeDeltaCallback = callback; - c.mergeTreeMaintenanceCallback= (main,op)=>{ - if(main.operation === MergeTreeMaintenanceType.ACKNOWLEDGED){ - callback(op) + c.mergeTreeMaintenanceCallback = (main,op) => { + if(main.operation === MergeTreeMaintenanceType.ACKNOWLEDGED) { + callback(op); } - } + }; }); this.roundLogLines.push(logHeaders); this.roundLogLines[0].forEach((v) => this.paddings.push(v.length)); @@ -109,14 +117,18 @@ export class TestClientLogger { } private addNewLogLine() { - if (this.incrementalLog) { - console.log(this.ackedLine.map((v, i) => v.padEnd(this.paddings[i])).join(" | ")); - console.log(this.ackedLine.map((v, i) => v.padEnd(this.paddings[i])).join(" | ")); + if(this.incrementalLog) { + while(this.roundLogLines.length > 0) { + const logLine = this.roundLogLines.shift(); + if(logLine.some((c)=>c.trim().length > 0)) { + console.log(logLine.map((v, i) => v.padEnd(this.paddings[i])).join(" | ")); + } + } } this.ackedLine = []; this.localLine = []; this.clients.forEach((cc, clientLogIndex)=>{ - const segStrings = this.getSegString(cc); + const segStrings = TestClientLogger.getSegString(cc); this.ackedLine.push("", segStrings.acked); this.localLine.push("", segStrings.local); @@ -153,26 +165,30 @@ export class TestClientLogger { return baseText; } - public toString() { - let str = - `_: Local State\n` - + `-: Deleted\n` - + `*: Unacked Insert and Delete\n` - + `${this.clients[0].getCollabWindow().minSeq}: msn/offset\n` - + `Op format ::@,\n` - + `sequence number represented as offset from msn. L means local.\n` - + `op types: 0) insert 1) remove 2) annotate\n`; - if (this.title) { - str += `${this.title}\n`; + public toString(excludeHeader: boolean = false) { + let str = ""; + if(!excludeHeader) { + str += + `_: Local State\n` + + `-: Deleted\n` + + `*: Unacked Insert and Delete\n` + + `${this.clients[0].getCollabWindow().minSeq}: msn/offset\n` + + `Op format ::@,\n` + + `sequence number represented as offset from msn. L means local.\n` + + `op types: 0) insert 1) remove 2) annotate\n`; + + if (this.title) { + str += `${this.title}\n`; + } } str += this.roundLogLines - .filter((line)=>line.some((c)=>c.trim().length >0)) + .filter((line) => line.some((c) => c.trim().length > 0)) .map((line) => line.map((v, i) => v.padEnd(this.paddings[i])).join(" | ")) .join("\n"); return str; } - private getSegString(client: TestClient): { acked: string, local: string } { + private static getSegString(client: TestClient): { acked: string, local: string } { let acked: string = ""; let local: string = ""; const nodes = [...client.mergeTree.root.children]; diff --git a/packages/dds/merge-tree/src/textSegment.ts b/packages/dds/merge-tree/src/textSegment.ts index 5caf763ff47a..a32fbe8c25f6 100644 --- a/packages/dds/merge-tree/src/textSegment.ts +++ b/packages/dds/merge-tree/src/textSegment.ts @@ -197,7 +197,6 @@ export class MergeTreeTextHelper { end: number, accumText: ITextAccumulatorType) => { let _start = start; if (TextSegment.is(segment)) { - let beginTags = ""; let endTags = ""; if (isTextAndMarkerAccumulator(accumText)) { diff --git a/packages/dds/ordered-collection/package.json b/packages/dds/ordered-collection/package.json index 3080b0f48ae0..26f96d9c08ee 100644 --- a/packages/dds/ordered-collection/package.json +++ b/packages/dds/ordered-collection/package.json @@ -67,7 +67,7 @@ "devDependencies": { "@fluid-internal/test-dds-utils": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/dds/register-collection/package.json b/packages/dds/register-collection/package.json index 72d496b039a0..aa3c2ed060f1 100644 --- a/packages/dds/register-collection/package.json +++ b/packages/dds/register-collection/package.json @@ -66,7 +66,7 @@ "devDependencies": { "@fluid-internal/test-dds-utils": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/dds/sequence/package.json b/packages/dds/sequence/package.json index 7a4cbcfeec9b..3832b3923b06 100644 --- a/packages/dds/sequence/package.json +++ b/packages/dds/sequence/package.json @@ -72,7 +72,7 @@ "devDependencies": { "@fluid-internal/test-dds-utils": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/gitresources": "^0.1035.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/server-services-client": "^0.1035.0-0", diff --git a/packages/dds/sequence/src/sequenceFactory.ts b/packages/dds/sequence/src/sequenceFactory.ts index d62615c24602..70356e23799d 100644 --- a/packages/dds/sequence/src/sequenceFactory.ts +++ b/packages/dds/sequence/src/sequenceFactory.ts @@ -94,10 +94,8 @@ export class SharedObjectSequenceFactory implements IChannelFactory { * For more info, please see [Github issue 8526](https://github.com/microsoft/FluidFramework/issues/8526) */ public static segmentFromSpec(segSpec: IJSONSegment) { - const runSegment = segSpec as IJSONRunSegment; if (runSegment.items) { - const seg = new SubSequence(runSegment.items); if (runSegment.props) { seg.addProperties(runSegment.props); @@ -133,7 +131,6 @@ export class SharedObjectSequenceFactory implements IChannelFactory { id: string, services: IChannelServices, attributes: IChannelAttributes): Promise { - const sharedSeq = new SharedObjectSequence(runtime, id, attributes); await sharedSeq.load(services); return sharedSeq; diff --git a/packages/dds/sequence/src/sparsematrix.ts b/packages/dds/sequence/src/sparsematrix.ts index 1e54cf697ad3..a2785948ca0f 100644 --- a/packages/dds/sequence/src/sparsematrix.ts +++ b/packages/dds/sequence/src/sparsematrix.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. */ -import { FluidObject, IFluidHandle, IFluidLoadable, IFluidObject } from "@fluidframework/core-interfaces"; +import { IFluidHandle } from "@fluidframework/core-interfaces"; import { BaseSegment, createGroupOp, @@ -159,7 +159,7 @@ export class RunSegment extends SubSequence { } public getTag(pos: number) { - + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return this.tags[pos]; } @@ -276,13 +276,11 @@ export class SparseMatrix extends SharedSegmentSequence { public getItem(row: number, col: number): // The return type is defined explicitly here to prevent TypeScript from generating dynamic imports - - Jsonable> { + Jsonable { const pos = rowColToPosition(row, col); - const { segment, offset } = - this.getContainingSegment(pos); + const { segment, offset } = this.getContainingSegment(pos); if (RunSegment.is(segment)) { - + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return segment.items[offset]; } else if (PaddingSegment.is(segment)) { return undefined; @@ -294,7 +292,7 @@ export class SparseMatrix extends SharedSegmentSequence { public getTag(row: number, col: number) { const { segment, offset } = this.getSegment(row, col); if (RunSegment.is(segment)) { - + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return segment.getTag(offset); } return undefined; diff --git a/packages/dds/shared-object-base/package.json b/packages/dds/shared-object-base/package.json index 953887325588..21e564088097 100644 --- a/packages/dds/shared-object-base/package.json +++ b/packages/dds/shared-object-base/package.json @@ -72,7 +72,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/packages/dds/shared-object-base/src/remoteObjectHandle.ts b/packages/dds/shared-object-base/src/remoteObjectHandle.ts index 2a48ec69c502..650e67b49b85 100644 --- a/packages/dds/shared-object-base/src/remoteObjectHandle.ts +++ b/packages/dds/shared-object-base/src/remoteObjectHandle.ts @@ -4,7 +4,7 @@ */ import { assert } from "@fluidframework/common-utils"; -import { RuntimeHeaders } from "@fluidframework/container-runtime" +import { RuntimeHeaders } from "@fluidframework/container-runtime"; import { IFluidHandle, IFluidHandleContext, diff --git a/packages/dds/shared-summary-block/package.json b/packages/dds/shared-summary-block/package.json index 4878b20a9371..1cee27d0dd44 100644 --- a/packages/dds/shared-summary-block/package.json +++ b/packages/dds/shared-summary-block/package.json @@ -66,7 +66,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/dds/task-manager/package.json b/packages/dds/task-manager/package.json index ba32449e0676..6a6f1897a868 100644 --- a/packages/dds/task-manager/package.json +++ b/packages/dds/task-manager/package.json @@ -69,7 +69,7 @@ "devDependencies": { "@fluid-internal/test-dds-utils": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/dds/test-dds-utils/package.json b/packages/dds/test-dds-utils/package.json index ba23a40b5ef2..4f4ae7e35a77 100644 --- a/packages/dds/test-dds-utils/package.json +++ b/packages/dds/test-dds-utils/package.json @@ -50,7 +50,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", "@types/node": "^14.18.0", diff --git a/packages/drivers/debugger/package.json b/packages/drivers/debugger/package.json index 5997fb50012a..0d2bde29b434 100644 --- a/packages/drivers/debugger/package.json +++ b/packages/drivers/debugger/package.json @@ -37,7 +37,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/packages/drivers/driver-base/package.json b/packages/drivers/driver-base/package.json index ab42d477d0ac..ac05d5e6e829 100644 --- a/packages/drivers/driver-base/package.json +++ b/packages/drivers/driver-base/package.json @@ -38,7 +38,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", diff --git a/packages/drivers/file-driver/package.json b/packages/drivers/file-driver/package.json index aee4207eba8c..561bfbe40020 100644 --- a/packages/drivers/file-driver/package.json +++ b/packages/drivers/file-driver/package.json @@ -37,7 +37,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", diff --git a/packages/drivers/fluidapp-odsp-urlResolver/package.json b/packages/drivers/fluidapp-odsp-urlResolver/package.json index 23a8854710de..cd6a683f6330 100644 --- a/packages/drivers/fluidapp-odsp-urlResolver/package.json +++ b/packages/drivers/fluidapp-odsp-urlResolver/package.json @@ -40,7 +40,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/packages/drivers/iframe-driver/package.json b/packages/drivers/iframe-driver/package.json index 8cc388051112..6b175be21f62 100644 --- a/packages/drivers/iframe-driver/package.json +++ b/packages/drivers/iframe-driver/package.json @@ -40,7 +40,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/packages/drivers/local-driver/package.json b/packages/drivers/local-driver/package.json index 167e074870d3..5e64f0befbb0 100644 --- a/packages/drivers/local-driver/package.json +++ b/packages/drivers/local-driver/package.json @@ -69,7 +69,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", "@types/jsrsasign": "^8.0.8", diff --git a/packages/drivers/odsp-driver-definitions/package.json b/packages/drivers/odsp-driver-definitions/package.json index 800ef2bd48f6..7cf5a6f45c15 100644 --- a/packages/drivers/odsp-driver-definitions/package.json +++ b/packages/drivers/odsp-driver-definitions/package.json @@ -34,7 +34,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/protocol-definitions": "^0.1027.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/packages/drivers/odsp-driver/package.json b/packages/drivers/odsp-driver/package.json index 0867922ed065..3142405fb684 100644 --- a/packages/drivers/odsp-driver/package.json +++ b/packages/drivers/odsp-driver/package.json @@ -74,7 +74,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/packages/drivers/odsp-driver/src/fetchSnapshot.ts b/packages/drivers/odsp-driver/src/fetchSnapshot.ts index 07d863c049ec..5fef652b176e 100644 --- a/packages/drivers/odsp-driver/src/fetchSnapshot.ts +++ b/packages/drivers/odsp-driver/src/fetchSnapshot.ts @@ -382,7 +382,7 @@ async function fetchSnapshotContentsCoreV1( // Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it. // This error thrown by server will contain the new redirect location. Look at the 404 error parsing // for futher reference here: \packages\utils\odsp-doclib-utils\src\odspErrorUtils.ts - const header = {"prefer": "manualredirect"}; + const header = { prefer: "manualredirect" }; const { body, headers } = getFormBodyAndHeaders( odspResolvedUrl, storageToken, snapshotOptions, header); headers.accept = "application/json"; diff --git a/packages/drivers/odsp-driver/src/getFileLink.ts b/packages/drivers/odsp-driver/src/getFileLink.ts index adf0168ad768..ec43d7278991 100644 --- a/packages/drivers/odsp-driver/src/getFileLink.ts +++ b/packages/drivers/odsp-driver/src/getFileLink.ts @@ -13,10 +13,9 @@ import { OdspResourceTokenFetchOptions, IdentityType, TokenFetcher, - tokenFromResponse, } from "@fluidframework/odsp-driver-definitions"; import { getUrlAndHeadersWithAuth } from "./getUrlAndHeadersWithAuth"; -import { fetchHelper, getWithRetryForTokenRefresh } from "./odspUtils"; +import { fetchHelper, getWithRetryForTokenRefresh, toInstrumentedOdspTokenFetcher } from "./odspUtils"; import { pkgVersion as driverVersion } from "./packageVersion"; // Store cached responses for the lifetime of web session as file link remains the same for given file item @@ -101,12 +100,21 @@ async function getFileLinkCore( let additionalProps; const fileLink = await getWithRetryForTokenRefresh(async (options) => { attempts++; - const token = await getToken({ ...options, ... odspUrlParts }); + const storageTokenFetcher = toInstrumentedOdspTokenFetcher( + logger, + odspUrlParts, + getToken, + true /* throwOnNullToken */, + ); + const storageToken = await storageTokenFetcher(options,"GetFileLinkCore"); + assert(storageToken !== null, + "Instrumented token fetcher with throwOnNullToken = true should never return null"); + const { url, headers } = getUrlAndHeadersWithAuth( `${odspUrlParts.siteUrl}/_api/web/GetFileByUrl(@a1)/ListItemAllFields/GetSharingInformation?@a1=${ encodeURIComponent(`'${fileItem.webDavUrl}'`) }`, - tokenFromResponse(token), + storageToken, false, ); const requestInit = { @@ -167,10 +175,19 @@ async function getFileItemLite( const fileItem = await getWithRetryForTokenRefresh(async (options) => { attempts++; const {siteUrl, driveId, itemId} = odspUrlParts; - const token = await getToken({ ...options, siteUrl, driveId, itemId}); + const storageTokenFetcher = toInstrumentedOdspTokenFetcher( + logger, + odspUrlParts, + getToken, + true /* throwOnNullToken */, + ); + const storageToken = await storageTokenFetcher(options,"GetFileItemLite"); + assert(storageToken !== null, + "Instrumented token fetcher with throwOnNullToken =true should never return null"); + const { url, headers } = getUrlAndHeadersWithAuth( `${siteUrl}/_api/v2.0/drives/${driveId}/items/${itemId}?select=webUrl,webDavUrl`, - tokenFromResponse(token), + storageToken, forceAccessTokenViaAuthorizationHeader, ); const requestInit = { method: "GET", headers }; diff --git a/packages/drivers/odsp-driver/src/odspDocumentService.ts b/packages/drivers/odsp-driver/src/odspDocumentService.ts index d3bd2198479d..4db30124a1c4 100644 --- a/packages/drivers/odsp-driver/src/odspDocumentService.ts +++ b/packages/drivers/odsp-driver/src/odspDocumentService.ts @@ -357,16 +357,16 @@ export class OdspDocumentService implements IDocumentService { }; const getResponseAndRefreshAfterDeltaMs = async () => { - let response = await this.cache.sessionJoinCache.addOrGet(this.joinSessionKey, executeFetch); + let _response = await this.cache.sessionJoinCache.addOrGet(this.joinSessionKey, executeFetch); // If the response does not contain refreshSessionDurationSeconds, then treat it as old flow and let the // cache entry to be treated as expired after 1 hour. - response.joinSessionResponse.refreshSessionDurationSeconds = - response.joinSessionResponse.refreshSessionDurationSeconds ?? 3600; + _response.joinSessionResponse.refreshSessionDurationSeconds = + _response.joinSessionResponse.refreshSessionDurationSeconds ?? 3600; return { - ...response, + ..._response, refreshAfterDeltaMs: this.calculateJoinSessionRefreshDelta( - response.entryTime, response.joinSessionResponse.refreshSessionDurationSeconds), - } + _response.entryTime, _response.joinSessionResponse.refreshSessionDurationSeconds), + }; }; let response = await getResponseAndRefreshAfterDeltaMs(); // This means that the cached entry has expired(This should not be possible if the response is fetched @@ -390,8 +390,8 @@ export class OdspDocumentService implements IDocumentService { ...props, }, error, - ) - });; + ); + }); } else { // Logging just for informational purposes to help with debugging as this is a new feature. this.mc.logger.sendErrorEvent({ diff --git a/packages/drivers/odsp-driver/src/odspDocumentServiceFactoryCore.ts b/packages/drivers/odsp-driver/src/odspDocumentServiceFactoryCore.ts index ef8ddc5ae090..507badb2dbed 100644 --- a/packages/drivers/odsp-driver/src/odspDocumentServiceFactoryCore.ts +++ b/packages/drivers/odsp-driver/src/odspDocumentServiceFactoryCore.ts @@ -22,6 +22,7 @@ import { IPersistedCache, HostStoragePolicy, IFileEntry, + IOdspUrlParts, } from "@fluidframework/odsp-driver-definitions"; import { v4 as uuid } from "uuid"; import { @@ -57,6 +58,11 @@ export class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory { ensureFluidResolvedUrl(createNewResolvedUrl); let odspResolvedUrl = getOdspResolvedUrl(createNewResolvedUrl); + const resolvedUrlData: IOdspUrlParts = { + siteUrl: odspResolvedUrl.siteUrl, + driveId: odspResolvedUrl.driveId, + itemId: odspResolvedUrl.itemId, + }; const [, queryString] = odspResolvedUrl.url.split("?"); const searchParams = new URLSearchParams(queryString); @@ -94,7 +100,7 @@ export class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory { odspResolvedUrl = await createNewFluidFile( toInstrumentedOdspTokenFetcher( odspLogger, - odspResolvedUrl, + resolvedUrlData, this.getStorageToken, true /* throwOnNullToken */, ), @@ -150,6 +156,11 @@ export class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory { cacheAndTrackerArg?: ICacheAndTracker, ): Promise { const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl); + const resolvedUrlData: IOdspUrlParts = { + siteUrl: odspResolvedUrl.siteUrl, + driveId: odspResolvedUrl.driveId, + itemId: odspResolvedUrl.itemId, + }; const cacheAndTracker = cacheAndTrackerArg ?? createOdspCacheAndTracker( this.persistedCache, this.nonPersistentCache, @@ -158,7 +169,7 @@ export class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory { const storageTokenFetcher = toInstrumentedOdspTokenFetcher( odspLogger, - odspResolvedUrl, + resolvedUrlData, this.getStorageToken, true /* throwOnNullToken */, ); @@ -167,7 +178,7 @@ export class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory { ? undefined : async (options: TokenFetchOptions) => toInstrumentedOdspTokenFetcher( odspLogger, - odspResolvedUrl, + resolvedUrlData, this.getWebsocketToken!, false /* throwOnNullToken */, )(options, "GetWebsocketToken"); diff --git a/packages/drivers/odsp-driver/src/odspDriverUrlResolver.ts b/packages/drivers/odsp-driver/src/odspDriverUrlResolver.ts index 4fc7d58ba1ad..0e9262b3e715 100644 --- a/packages/drivers/odsp-driver/src/odspDriverUrlResolver.ts +++ b/packages/drivers/odsp-driver/src/odspDriverUrlResolver.ts @@ -167,13 +167,13 @@ export class OdspDriverUrlResolver implements IUrlResolver { // back-compat: IFluidCodeDetails usage to be removed in 0.58.0 let containerPackageName; if (packageInfoSource && "name" in packageInfoSource) { - containerPackageName = packageInfoSource.name + containerPackageName = packageInfoSource.name; } else if (isFluidPackage(packageInfoSource?.package)) { - containerPackageName = packageInfoSource?.package.name + containerPackageName = packageInfoSource?.package.name; } else { - containerPackageName = packageInfoSource?.package + containerPackageName = packageInfoSource?.package; } - containerPackageName = containerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName + containerPackageName = containerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName; return createOdspUrl({ ... odspResolvedUrl, diff --git a/packages/drivers/odsp-driver/src/odspDriverUrlResolverForShareLink.ts b/packages/drivers/odsp-driver/src/odspDriverUrlResolverForShareLink.ts index 62d539e6542d..a2187e1fe9dd 100644 --- a/packages/drivers/odsp-driver/src/odspDriverUrlResolverForShareLink.ts +++ b/packages/drivers/odsp-driver/src/odspDriverUrlResolverForShareLink.ts @@ -11,15 +11,11 @@ import { IUrlResolver, } from "@fluidframework/driver-definitions"; import { ITelemetryBaseLogger, ITelemetryLogger } from "@fluidframework/common-definitions"; -import { NonRetryableError } from "@fluidframework/driver-utils"; -import { PerformanceEvent } from "@fluidframework/telemetry-utils"; import { IOdspResolvedUrl, IdentityType, - isTokenFromCache, OdspResourceTokenFetchOptions, TokenFetcher, - OdspErrorType, } from "@fluidframework/odsp-driver-definitions"; import { getLocatorFromOdspUrl, @@ -32,7 +28,6 @@ import { createOdspUrl } from "./createOdspUrl"; import { OdspDriverUrlResolver } from "./odspDriverUrlResolver"; import { getOdspResolvedUrl, createOdspLogger } from "./odspUtils"; import { getFileLink } from "./getFileLink"; -import { pkgVersion as driverVersion } from "./packageVersion"; /** * Properties passed to the code responsible for fetching share link for a file. @@ -77,7 +72,7 @@ export class OdspDriverUrlResolverForShareLink implements IUrlResolver { if (shareLinkFetcherProps) { this.shareLinkFetcherProps = { ...shareLinkFetcherProps, - tokenFetcher: this.toInstrumentedTokenFetcher(this.logger, shareLinkFetcherProps.tokenFetcher), + tokenFetcher: shareLinkFetcherProps.tokenFetcher, }; } } @@ -157,27 +152,6 @@ export class OdspDriverUrlResolverForShareLink implements IUrlResolver { return url.href; } - private toInstrumentedTokenFetcher( - logger: ITelemetryLogger, - tokenFetcher: TokenFetcher, - ): TokenFetcher { - return async (options: OdspResourceTokenFetchOptions) => { - return PerformanceEvent.timedExecAsync( - logger, - { eventName: "GetSharingLinkToken" }, - async (event) => tokenFetcher(options).then((tokenResponse) => { - if (tokenResponse === null) { - throw new NonRetryableError( - "Token callback returned null for share link", - OdspErrorType.fetchTokenError, - { driverVersion }); - } - event.end({ fromCache: isTokenFromCache(tokenResponse) }); - return tokenResponse; - })); - }; - } - private async getShareLinkPromise(resolvedUrl: IOdspResolvedUrl): Promise { if (this.shareLinkFetcherProps === undefined) { throw new Error("Failed to get share link because share link fetcher props are missing"); @@ -226,13 +200,13 @@ export class OdspDriverUrlResolverForShareLink implements IUrlResolver { // back-compat: IFluidCodeDetails usage to be removed in 0.58.0 let containerPackageName; if (packageInfoSource && "name" in packageInfoSource) { - containerPackageName = packageInfoSource.name + containerPackageName = packageInfoSource.name; } else if (isFluidPackage(packageInfoSource?.package)) { - containerPackageName = packageInfoSource?.package.name + containerPackageName = packageInfoSource?.package.name; } else { - containerPackageName = packageInfoSource?.package + containerPackageName = packageInfoSource?.package; } - containerPackageName = containerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName + containerPackageName = containerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName; storeLocatorInOdspUrl(shareLinkUrl, { siteUrl: odspResolvedUrl.siteUrl, diff --git a/packages/drivers/odsp-driver/src/odspUtils.ts b/packages/drivers/odsp-driver/src/odspUtils.ts index 1304323d37e3..af847add0063 100644 --- a/packages/drivers/odsp-driver/src/odspUtils.ts +++ b/packages/drivers/odsp-driver/src/odspUtils.ts @@ -32,6 +32,7 @@ import { ICacheEntry, snapshotKey, InstrumentedStorageTokenFetcher, + IOdspUrlParts, } from "@fluidframework/odsp-driver-definitions"; import { fetch } from "./fetch"; import { pkgVersion as driverVersion } from "./packageVersion"; @@ -271,7 +272,7 @@ export function evalBlobsAndTrees(snapshot: IOdspSnapshot) { export function toInstrumentedOdspTokenFetcher( logger: ITelemetryLogger, - resolvedUrl: IOdspResolvedUrl, + resolvedUrlParts: IOdspUrlParts, tokenFetcher: TokenFetcher, throwOnNullToken: boolean, ): InstrumentedStorageTokenFetcher { @@ -290,9 +291,7 @@ export function toInstrumentedOdspTokenFetcher( }, async (event) => tokenFetcher({ ...options, - siteUrl: resolvedUrl.siteUrl, - driveId: resolvedUrl.driveId, - itemId: resolvedUrl.itemId, + ...resolvedUrlParts, }).then((tokenResponse) => { const token = tokenFromResponse(tokenResponse); // This event alone generates so many events that is materially impacts cost of telemetry diff --git a/packages/drivers/odsp-driver/src/prefetchLatestSnapshot.ts b/packages/drivers/odsp-driver/src/prefetchLatestSnapshot.ts index 76e8e00d0383..5350f9c336f7 100644 --- a/packages/drivers/odsp-driver/src/prefetchLatestSnapshot.ts +++ b/packages/drivers/odsp-driver/src/prefetchLatestSnapshot.ts @@ -13,6 +13,7 @@ import { ISnapshotOptions, OdspResourceTokenFetchOptions, TokenFetcher, + IOdspUrlParts, } from "@fluidframework/odsp-driver-definitions"; import { ChildLogger, PerformanceEvent } from "@fluidframework/telemetry-utils"; import { @@ -52,9 +53,14 @@ export async function prefetchLatestSnapshot( const odspLogger = createOdspLogger(ChildLogger.create(logger, "PrefetchSnapshot")); const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl); + const resolvedUrlData: IOdspUrlParts = { + siteUrl: odspResolvedUrl.siteUrl, + driveId: odspResolvedUrl.driveId, + itemId: odspResolvedUrl.itemId, + }; const storageTokenFetcher = toInstrumentedOdspTokenFetcher( odspLogger, - odspResolvedUrl, + resolvedUrlData, getStorageToken, true /* throwOnNullToken */, ); diff --git a/packages/drivers/odsp-driver/src/test/joinSessionPeriodicCall.spec.ts b/packages/drivers/odsp-driver/src/test/joinSessionPeriodicCall.spec.ts index 14674a5c2c3e..8043fafd11ad 100644 --- a/packages/drivers/odsp-driver/src/test/joinSessionPeriodicCall.spec.ts +++ b/packages/drivers/odsp-driver/src/test/joinSessionPeriodicCall.spec.ts @@ -3,8 +3,9 @@ * Licensed under the MIT License. */ -import { stub, useFakeTimers, SinonFakeTimers } from "sinon"; import { strict as assert } from "assert"; +import { IClient } from "@fluidframework/protocol-definitions"; +import { stub, useFakeTimers, SinonFakeTimers } from "sinon"; import * as odspDocumentDeltaConnection from "../odspDocumentDeltaConnection"; import * as joinSession from "../vroom"; import { OdspDocumentServiceFactory } from "../odspDocumentServiceFactory"; @@ -13,7 +14,6 @@ import { OdspFluidDataStoreLocator } from "../contractsPublic"; import { createOdspUrl } from "../createOdspUrl"; import { OdspDriverUrlResolver } from "../odspDriverUrlResolver"; import { OdspDocumentService } from "../odspDocumentService"; -import { IClient } from "@fluidframework/protocol-definitions"; import { ISocketStorageDiscovery } from "../contracts"; import { OdspDocumentDeltaConnection } from "../odspDocumentDeltaConnection"; @@ -67,7 +67,7 @@ describe("joinSessions Tests", () => { joinSessionResponse.refreshSessionDurationSeconds = time; const joinSessionStub = stub( joinSession, "fetchJoinSession").callsFake( - () => Promise.resolve(joinSessionResponse)); + async () => joinSessionResponse); return joinSessionStub; } @@ -98,12 +98,12 @@ describe("joinSessions Tests", () => { disposed: false, submit: (message) => {}, submitSignal: (message) => {}, - on: (op: any, func?:any) => {}, + on: (op: any, func?: any) => {}, }; const createDeltaConnectionStub = stub( odspDocumentDeltaConnection.OdspDocumentDeltaConnection, "create").callsFake( - () => Promise.resolve(deltaConnection as any as OdspDocumentDeltaConnection)); - let joinSessionStub = addJoinSessionStub(100) + async () => deltaConnection as any as OdspDocumentDeltaConnection); + let joinSessionStub = addJoinSessionStub(100); await service.connectToDeltaStream(client); createDeltaConnectionStub.restore(); joinSessionStub.restore(); diff --git a/packages/drivers/odsp-driver/src/test/odspError.spec.ts b/packages/drivers/odsp-driver/src/test/odspError.spec.ts index 94e469b8731d..3ed53a8e4830 100644 --- a/packages/drivers/odsp-driver/src/test/odspError.spec.ts +++ b/packages/drivers/odsp-driver/src/test/odspError.spec.ts @@ -272,9 +272,9 @@ describe("Odsp Error", () => { const responseText = { error: { "@error.redirectLocation": redirectLocation, - code: "itemNotFound", - message: "The site has been moved to a new location.", - innerError: {}, + "code": "itemNotFound", + "message": "The site has been moved to a new location.", + "innerError": {}, }, }; const error: any = createOdspNetworkErrorWithResponse( diff --git a/packages/drivers/odsp-urlResolver/package.json b/packages/drivers/odsp-urlResolver/package.json index 242ad83b4850..58004f477d6e 100644 --- a/packages/drivers/odsp-urlResolver/package.json +++ b/packages/drivers/odsp-urlResolver/package.json @@ -39,7 +39,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/packages/drivers/replay-driver/package.json b/packages/drivers/replay-driver/package.json index 232e2eab4edb..45dd493f69da 100644 --- a/packages/drivers/replay-driver/package.json +++ b/packages/drivers/replay-driver/package.json @@ -38,7 +38,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/packages/drivers/routerlicious-driver/package.json b/packages/drivers/routerlicious-driver/package.json index 1cf71d32ed27..36bf57d06742 100644 --- a/packages/drivers/routerlicious-driver/package.json +++ b/packages/drivers/routerlicious-driver/package.json @@ -73,7 +73,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/packages/drivers/routerlicious-driver/src/wholeSummaryDocumentStorageService.ts b/packages/drivers/routerlicious-driver/src/wholeSummaryDocumentStorageService.ts index 784d81534c79..034ec26bcf7a 100644 --- a/packages/drivers/routerlicious-driver/src/wholeSummaryDocumentStorageService.ts +++ b/packages/drivers/routerlicious-driver/src/wholeSummaryDocumentStorageService.ts @@ -64,9 +64,9 @@ export class WholeSummaryDocumentStorageService implements IDocumentStorageServi // Fetch latest summary, cache it, and return its id. if (this.firstVersionsCall && count === 1) { this.firstVersionsCall = false; - const { id, snapshotTree } = await this.fetchAndCacheSnapshotTree(latestSnapshotId); + const { id: _id, snapshotTree } = await this.fetchAndCacheSnapshotTree(latestSnapshotId); return [{ - id, + id: _id, treeId: snapshotTree.id!, }]; } diff --git a/packages/drivers/routerlicious-host/package.json b/packages/drivers/routerlicious-host/package.json index ffbf1a8a0252..67bbd1f46cad 100644 --- a/packages/drivers/routerlicious-host/package.json +++ b/packages/drivers/routerlicious-host/package.json @@ -36,7 +36,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/protocol-definitions": "^0.1027.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/packages/drivers/routerlicious-urlResolver/package.json b/packages/drivers/routerlicious-urlResolver/package.json index 86f6b3186e5e..3a0a884d21c2 100644 --- a/packages/drivers/routerlicious-urlResolver/package.json +++ b/packages/drivers/routerlicious-urlResolver/package.json @@ -40,7 +40,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/packages/drivers/tinylicious-driver/package.json b/packages/drivers/tinylicious-driver/package.json index e3d41b1bf1d4..0d6d6c2b92fc 100644 --- a/packages/drivers/tinylicious-driver/package.json +++ b/packages/drivers/tinylicious-driver/package.json @@ -38,7 +38,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-tools": "^0.2.3074", "@rushstack/eslint-config": "^2.5.1", "@types/jsrsasign": "^8.0.8", diff --git a/packages/framework/aqueduct/package.json b/packages/framework/aqueduct/package.json index be1dd6aa4bb0..083ae90ba716 100644 --- a/packages/framework/aqueduct/package.json +++ b/packages/framework/aqueduct/package.json @@ -77,7 +77,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/packages/framework/azure-client/package.json b/packages/framework/azure-client/package.json index f9090248552f..253f25f784c1 100644 --- a/packages/framework/azure-client/package.json +++ b/packages/framework/azure-client/package.json @@ -56,7 +56,7 @@ "@fluidframework/aqueduct": "^0.58.1000", "@fluidframework/azure-local-service": "^0.1.38773", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/test-client-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/packages/framework/azure-service-utils/package.json b/packages/framework/azure-service-utils/package.json index 2fff5fb803fc..6d6a01840724 100644 --- a/packages/framework/azure-service-utils/package.json +++ b/packages/framework/azure-service-utils/package.json @@ -36,7 +36,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/jsrsasign": "^8.0.8", diff --git a/packages/framework/data-object-base/package.json b/packages/framework/data-object-base/package.json index 96b9479b5c2d..deac8d364f91 100644 --- a/packages/framework/data-object-base/package.json +++ b/packages/framework/data-object-base/package.json @@ -68,7 +68,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/packages/framework/dds-interceptions/package.json b/packages/framework/dds-interceptions/package.json index ff86b3754d01..c9bc9196cc26 100644 --- a/packages/framework/dds-interceptions/package.json +++ b/packages/framework/dds-interceptions/package.json @@ -64,7 +64,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/framework/fluid-framework/package.json b/packages/framework/fluid-framework/package.json index 9f274fa88e2c..f100060dad99 100644 --- a/packages/framework/fluid-framework/package.json +++ b/packages/framework/fluid-framework/package.json @@ -36,7 +36,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", diff --git a/packages/framework/fluid-static/package.json b/packages/framework/fluid-static/package.json index c29cbd8d881d..3daed916a011 100644 --- a/packages/framework/fluid-static/package.json +++ b/packages/framework/fluid-static/package.json @@ -45,7 +45,7 @@ "devDependencies": { "@fluid-experimental/get-container": "^0.58.1000", "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", diff --git a/packages/framework/request-handler/package.json b/packages/framework/request-handler/package.json index f62defa8b028..8b890dd5ff81 100644 --- a/packages/framework/request-handler/package.json +++ b/packages/framework/request-handler/package.json @@ -63,7 +63,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/framework/synthesize/package.json b/packages/framework/synthesize/package.json index 51fe92e76b4e..05a7792d3e41 100644 --- a/packages/framework/synthesize/package.json +++ b/packages/framework/synthesize/package.json @@ -61,7 +61,7 @@ "@fluidframework/build-common": "^0.23.0", "@fluidframework/core-interfaces": "^0.42.0", "@fluidframework/datastore": "^0.58.1000", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/packages/framework/test-client-utils/package.json b/packages/framework/test-client-utils/package.json index 79aff4ee3c40..e5be0c857f6e 100644 --- a/packages/framework/test-client-utils/package.json +++ b/packages/framework/test-client-utils/package.json @@ -37,7 +37,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@typescript-eslint/eslint-plugin": "~5.9.0", diff --git a/packages/framework/tinylicious-client/package.json b/packages/framework/tinylicious-client/package.json index 1d4effddfab1..55d02a7e50f1 100644 --- a/packages/framework/tinylicious-client/package.json +++ b/packages/framework/tinylicious-client/package.json @@ -50,7 +50,7 @@ }, "devDependencies": { "@fluidframework/aqueduct": "^0.58.1000", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/packages/framework/undo-redo/package.json b/packages/framework/undo-redo/package.json index 03e5b165d8eb..b17e68f7f996 100644 --- a/packages/framework/undo-redo/package.json +++ b/packages/framework/undo-redo/package.json @@ -62,7 +62,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/framework/view-adapters/package.json b/packages/framework/view-adapters/package.json index 16224dcde03a..9ba4a58febbb 100644 --- a/packages/framework/view-adapters/package.json +++ b/packages/framework/view-adapters/package.json @@ -35,7 +35,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/react": "^16.9.15", diff --git a/packages/framework/view-interfaces/package.json b/packages/framework/view-interfaces/package.json index 7addf65e8544..b82966ccacc3 100644 --- a/packages/framework/view-interfaces/package.json +++ b/packages/framework/view-interfaces/package.json @@ -32,7 +32,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/react": "^16.9.15", diff --git a/packages/loader/container-loader/package.json b/packages/loader/container-loader/package.json index c1e3a810f6fa..e3f5b0e74d32 100644 --- a/packages/loader/container-loader/package.json +++ b/packages/loader/container-loader/package.json @@ -73,7 +73,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-loader-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/loader/container-loader/src/connectionManager.ts b/packages/loader/container-loader/src/connectionManager.ts index da48ebb3f27f..3794defc6c87 100644 --- a/packages/loader/container-loader/src/connectionManager.ts +++ b/packages/loader/container-loader/src/connectionManager.ts @@ -856,9 +856,9 @@ export class ConnectionManager implements IConnectionManager { // Always connect in write mode after getting nacked. private readonly nackHandler = (documentId: string, messages: INack[]) => { const message = messages[0]; - if (this._readonlyPermissions) { + if (this._readonlyPermissions === true) { this.props.closeHandler(createWriteError("writeOnReadOnlyDocument", { driverVersion: undefined })); - return + return; } const reconnectInfo = getNackReconnectInfo(message.content); diff --git a/packages/loader/container-loader/src/containerContext.ts b/packages/loader/container-loader/src/containerContext.ts index 481a65c2502e..90d96cf192ff 100644 --- a/packages/loader/container-loader/src/containerContext.ts +++ b/packages/loader/container-loader/src/containerContext.ts @@ -4,15 +4,7 @@ */ import { ITelemetryLogger } from "@fluidframework/common-definitions"; -import { - IFluidObject, - IRequest, - IResponse, - IFluidCodeDetails, - IFluidCodeDetailsComparer, - IProvideFluidCodeDetailsComparer, - FluidObject, -} from "@fluidframework/core-interfaces"; +import { assert, LazyPromise } from "@fluidframework/common-utils"; import { IAudience, IContainerContext, @@ -27,7 +19,17 @@ import { ICodeLoader, IProvideRuntimeFactory, } from "@fluidframework/container-definitions"; +import { + IFluidObject, + IRequest, + IResponse, + IFluidCodeDetails, + IFluidCodeDetailsComparer, + IProvideFluidCodeDetailsComparer, + FluidObject, +} from "@fluidframework/core-interfaces"; import { IDocumentStorageService } from "@fluidframework/driver-definitions"; +import { isFluidResolvedUrl } from "@fluidframework/driver-utils"; import { IClientConfiguration, IClientDetails, @@ -42,9 +44,7 @@ import { MessageType, } from "@fluidframework/protocol-definitions"; import { PerformanceEvent } from "@fluidframework/telemetry-utils"; -import { assert, LazyPromise } from "@fluidframework/common-utils"; import { Container } from "./container"; -import { isFluidResolvedUrl } from "@fluidframework/driver-utils"; import { ICodeDetailsLoader, IFluidModuleWithDetails } from "./loader"; const PackageNotFactoryError = "Code package does not implement IRuntimeFactory"; diff --git a/packages/loader/container-loader/src/deltaManager.ts b/packages/loader/container-loader/src/deltaManager.ts index 9a571202e9ff..134bcb9f8366 100644 --- a/packages/loader/container-loader/src/deltaManager.ts +++ b/packages/loader/container-loader/src/deltaManager.ts @@ -25,6 +25,7 @@ import { normalizeError, logIfFalse, safeRaiseEvent, + TelemetryDataTag, } from "@fluidframework/telemetry-utils"; import { IDocumentDeltaStorageService, @@ -53,7 +54,6 @@ import { IConnectionManagerFactoryArgs, IConnectionManager, } from "./contracts"; -import { TelemetryDataTag } from "@fluidframework/telemetry-utils"; export interface IConnectionArgs { mode?: ConnectionMode; @@ -184,7 +184,6 @@ export class DeltaManager public get clientDetails() { return this.connectionManager.clientDetails; } public submit(type: MessageType, contents: any, batch = false, metadata?: any) { - const messagePartial: Omit = { contents: JSON.stringify(contents), metadata, @@ -582,7 +581,7 @@ export class DeltaManager reason: { value: reason, tag: TelemetryDataTag.PackageData, - } + }, }); this.messageBuffer.length = 0; } diff --git a/packages/loader/container-loader/src/test/connectionManager.spec.ts b/packages/loader/container-loader/src/test/connectionManager.spec.ts index 91713fb3ac16..07d7da16c518 100644 --- a/packages/loader/container-loader/src/test/connectionManager.spec.ts +++ b/packages/loader/container-loader/src/test/connectionManager.spec.ts @@ -21,7 +21,10 @@ describe("connectionManager", () => { let _mockDeltaConnection: MockDocumentDeltaConnection | undefined; const mockDocumentService = new MockDocumentService( undefined /* deltaStorageFactory */, - () => { _mockDeltaConnection = new MockDocumentDeltaConnection(`mock_client_${nextClientId++}`); return _mockDeltaConnection }, + () => { + _mockDeltaConnection = new MockDocumentDeltaConnection(`mock_client_${nextClientId++}`); + return _mockDeltaConnection; + }, ); const client: Partial = { details: { capabilities: { interactive: true } }, @@ -119,7 +122,12 @@ describe("connectionManager", () => { // Assert II assert(oldConnection.disposed, "Old connection should be disposed after emitting disconnect"); assert.equal(connection.clientId, "mock_client_2", "New connection should have expected id"); - mockLogger.assertMatchAny([{ eventName: "reconnectingDespiteFatalError", reconnectMode: "Enabled", error: "Fatal disconnect reason", canRetry: false, }]); + mockLogger.assertMatchAny([{ + eventName: "reconnectingDespiteFatalError", + reconnectMode: "Enabled", + error: "Fatal disconnect reason", + canRetry: false, + }]); assert(!closed, "Don't expect closeHandler to be called even when connection emits a non-retryable disconnect"); assert.equal(disconnectCount, 2, "Expected 2 disconnects from emitting an error and disconnect"); assert.equal(connectionCount, 3, "Expected 3 connections after the two disconnects"); diff --git a/packages/loader/container-utils/package.json b/packages/loader/container-utils/package.json index 24132e8db65e..1f4f50ae1322 100644 --- a/packages/loader/container-utils/package.json +++ b/packages/loader/container-utils/package.json @@ -62,7 +62,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/loader/container-utils/src/error.ts b/packages/loader/container-utils/src/error.ts index 74627eb572fa..ef7816c2f4f6 100644 --- a/packages/loader/container-utils/src/error.ts +++ b/packages/loader/container-utils/src/error.ts @@ -157,7 +157,7 @@ export class DataProcessingError extends LoggingError implements IErrorBase, IFl const props = { dataProcessingError: 1, dataProcessingCodepath, - ...(sequencedMessage === undefined ? undefined : extractSafePropertiesFromMessage(sequencedMessage)) + ...(sequencedMessage === undefined ? undefined : extractSafePropertiesFromMessage(sequencedMessage)), }; const normalizedError = normalizeError(originalError, { props }); diff --git a/packages/loader/driver-utils/package.json b/packages/loader/driver-utils/package.json index 700797c29345..e48f43c5beab 100644 --- a/packages/loader/driver-utils/package.json +++ b/packages/loader/driver-utils/package.json @@ -68,7 +68,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/loader/test-loader-utils/package.json b/packages/loader/test-loader-utils/package.json index b91092bd77ed..c0dcd181b0b1 100644 --- a/packages/loader/test-loader-utils/package.json +++ b/packages/loader/test-loader-utils/package.json @@ -33,7 +33,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@typescript-eslint/eslint-plugin": "~5.9.0", "@typescript-eslint/parser": "~5.9.0", diff --git a/packages/loader/web-code-loader/package.json b/packages/loader/web-code-loader/package.json index 47ec71350adf..ad8c965f88fd 100644 --- a/packages/loader/web-code-loader/package.json +++ b/packages/loader/web-code-loader/package.json @@ -34,7 +34,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/protocol-definitions": "^0.1027.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/packages/runtime/agent-scheduler/package.json b/packages/runtime/agent-scheduler/package.json index 5b133f849bec..9977936805b1 100644 --- a/packages/runtime/agent-scheduler/package.json +++ b/packages/runtime/agent-scheduler/package.json @@ -60,7 +60,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", "@types/node": "^14.18.0", diff --git a/packages/runtime/container-runtime-definitions/package.json b/packages/runtime/container-runtime-definitions/package.json index 651566d8ee1e..5ae48188eb99 100644 --- a/packages/runtime/container-runtime-definitions/package.json +++ b/packages/runtime/container-runtime-definitions/package.json @@ -49,7 +49,7 @@ "@fluidframework/container-runtime-definitions-0.55.0": "npm:@fluidframework/container-runtime-definitions@0.55.0", "@fluidframework/container-runtime-definitions-0.56.0": "npm:@fluidframework/container-runtime-definitions@0.56.0", "@fluidframework/container-runtime-definitions-0.57.0": "npm:@fluidframework/container-runtime-definitions@0.57.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@typescript-eslint/eslint-plugin": "~5.9.0", diff --git a/packages/runtime/container-runtime/package.json b/packages/runtime/container-runtime/package.json index 5729d638e2d4..7b4032f1c113 100644 --- a/packages/runtime/container-runtime/package.json +++ b/packages/runtime/container-runtime/package.json @@ -76,7 +76,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/runtime/container-runtime/src/batchTracker.ts b/packages/runtime/container-runtime/src/batchTracker.ts index 837f21bcabd2..7f9d5a70766a 100644 --- a/packages/runtime/container-runtime/src/batchTracker.ts +++ b/packages/runtime/container-runtime/src/batchTracker.ts @@ -3,11 +3,11 @@ * Licensed under the MIT License. */ +import EventEmitter from "events"; import { ITelemetryLogger } from "@fluidframework/common-definitions"; import { assert, performance } from "@fluidframework/common-utils"; import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions"; import { ChildLogger } from "@fluidframework/telemetry-utils"; -import EventEmitter from "events"; export class BatchTracker { private readonly logger: ITelemetryLogger; @@ -77,4 +77,4 @@ export const BindBatchTracker = ( logger: ITelemetryLogger, batchLengthThreshold: number = 128, batchCountSamplingRate: number = 1000, -) => new BatchTracker(batchEventEmitter, logger, batchLengthThreshold, batchCountSamplingRate) +) => new BatchTracker(batchEventEmitter, logger, batchLengthThreshold, batchCountSamplingRate); diff --git a/packages/runtime/container-runtime/src/dataStore.ts b/packages/runtime/container-runtime/src/dataStore.ts index 54c2ae896323..29f463a330e8 100644 --- a/packages/runtime/container-runtime/src/dataStore.ts +++ b/packages/runtime/container-runtime/src/dataStore.ts @@ -123,7 +123,7 @@ class DataStore implements IDataStore { private readonly fluidDataStoreChannel: IFluidDataStoreChannel, private readonly internalId: string, private readonly runtime: ContainerRuntime, - private datastores: DataStores, + private readonly datastores: DataStores, private readonly logger: ITelemetryLogger, ) { } public get IFluidRouter() { return this.fluidDataStoreChannel; } diff --git a/packages/runtime/container-runtime/src/garbageCollection.ts b/packages/runtime/container-runtime/src/garbageCollection.ts index 228774231a9d..353ac0e8c50d 100644 --- a/packages/runtime/container-runtime/src/garbageCollection.ts +++ b/packages/runtime/container-runtime/src/garbageCollection.ts @@ -35,10 +35,9 @@ import { MonitoringContext, PerformanceEvent, TelemetryDataTag, - } from "@fluidframework/telemetry-utils"; -import { RuntimeHeaders } from "."; +} from "@fluidframework/telemetry-utils"; -import { IGCRuntimeOptions } from "./containerRuntime"; +import { IGCRuntimeOptions, RuntimeHeaders } from "./containerRuntime"; import { getSummaryForDatastores } from "./dataStores"; import { getGCVersion, @@ -96,7 +95,7 @@ interface IUnreferencedEvent { lastSummaryTime?: number; externalRequest?: boolean; viaHandle?: boolean; -}; +} /** Defines the APIs for the runtime object to be passed to the garbage collector. */ export interface IGarbageCollectionRuntime { @@ -186,7 +185,7 @@ class UnreferencedStateTracker { } // The node isn't inactive yet. Restart a timer for the duration remaining for it to become inactive. - const remainingDurationMs = this.inactiveTimeoutMs - unreferencedDurationMs; + const remainingDurationMs = this.inactiveTimeoutMs - unreferencedDurationMs; if (this.timer === undefined) { this.timer = new Timer(remainingDurationMs, () => { this._inactive = true; }); } @@ -322,7 +321,7 @@ export class GarbageCollector implements IGarbageCollector { // per event per node. private readonly loggedUnreferencedEvents: Set = new Set(); // Queue for unreferenced events that should be logged the next time GC runs. - private pendingEventsQueue: IUnreferencedEvent[] = []; + private readonly pendingEventsQueue: IUnreferencedEvent[] = []; protected constructor( private readonly provider: IGarbageCollectionRuntime, diff --git a/packages/runtime/container-runtime/src/summaryGenerator.ts b/packages/runtime/container-runtime/src/summaryGenerator.ts index 0b83d63a891c..9a9ac6d65ab4 100644 --- a/packages/runtime/container-runtime/src/summaryGenerator.ts +++ b/packages/runtime/container-runtime/src/summaryGenerator.ts @@ -201,7 +201,7 @@ export class SummaryGenerator { fullTree, timeSinceLastAttempt, timeSinceLastSummary, - } + }; const summarizeEvent = PerformanceEvent.start(logger, { eventName: "Summarize", diff --git a/packages/runtime/container-runtime/src/summaryManager.ts b/packages/runtime/container-runtime/src/summaryManager.ts index a25410097d5f..92da383fe2e8 100644 --- a/packages/runtime/container-runtime/src/summaryManager.ts +++ b/packages/runtime/container-runtime/src/summaryManager.ts @@ -99,7 +99,6 @@ export class SummaryManager implements IDisposable { }: Readonly> = {}, private readonly summarizerOptions?: Readonly>, ) { - this.logger = ChildLogger.create( parentLogger, "SummaryManager", diff --git a/packages/runtime/container-runtime/src/test/batchTracker.spec.ts b/packages/runtime/container-runtime/src/test/batchTracker.spec.ts index d14aeb6353bc..fdfb924c8288 100644 --- a/packages/runtime/container-runtime/src/test/batchTracker.spec.ts +++ b/packages/runtime/container-runtime/src/test/batchTracker.spec.ts @@ -3,9 +3,9 @@ * Licensed under the MIT License. */ +import EventEmitter from "events"; import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions"; import { MockLogger } from "@fluidframework/telemetry-utils"; -import EventEmitter from "events"; import { BatchTracker } from "../batchTracker"; describe("Runtime", () => { @@ -20,14 +20,14 @@ describe("Runtime", () => { let ticks = 0; new BatchTracker(emitter, mockLogger, 5, 100, () => ticks); - emitter.emit("batchBegin", batchMessage(2)) + emitter.emit("batchBegin", batchMessage(2)); emitter.emit("batchEnd", /* error */ undefined, batchMessage(5)); - emitter.emit("batchBegin", batchMessage(1)) + emitter.emit("batchBegin", batchMessage(1)); ticks += 10; emitter.emit("batchEnd", /* error */ undefined, batchMessage(5)); - emitter.emit("batchBegin", batchMessage(1)) + emitter.emit("batchBegin", batchMessage(1)); ticks += 20; emitter.emit("batchEnd", new Error(), batchMessage(8)); @@ -57,7 +57,7 @@ describe("Runtime", () => { new BatchTracker(emitter, mockLogger, 100, 3, () => ticks); for (let i = 1; i <= 10; i++) { - emitter.emit("batchBegin", batchMessage(1)) + emitter.emit("batchBegin", batchMessage(1)); ticks += i; emitter.emit("batchEnd", /* error */ undefined, batchMessage(i)); } @@ -91,5 +91,5 @@ describe("Runtime", () => { const batchMessage = (sequenceNumber: number): ISequencedDocumentMessage => ({ sequenceNumber, referenceSequenceNumber: sequenceNumber, - } as ISequencedDocumentMessage) + } as ISequencedDocumentMessage); }); diff --git a/packages/runtime/container-runtime/src/test/containerRuntime.spec.ts b/packages/runtime/container-runtime/src/test/containerRuntime.spec.ts index 78e7dc358733..44453401efbd 100644 --- a/packages/runtime/container-runtime/src/test/containerRuntime.spec.ts +++ b/packages/runtime/container-runtime/src/test/containerRuntime.spec.ts @@ -558,7 +558,7 @@ describe("Runtime", () => { return { localAck: false, localOpMetadata: undefined }; }, } as PendingStateManager; - } + }; const getMockDataStores = (): DataStores => { return { processFluidDataStoreOp: @@ -567,7 +567,7 @@ describe("Runtime", () => { _localMessageMetadata: unknown) => { }, setConnectionState: (_connected: boolean, _clientId?: string) => { }, } as DataStores; - } + }; const getFirstContainerError = (): ICriticalContainerError => { assert.ok(containerErrors.length > 0, "Container should have errors"); @@ -590,12 +590,12 @@ describe("Runtime", () => { function patchRuntime( pendingStateManager: PendingStateManager, - maxReconnects: number | undefined = undefined + _maxReconnects: number | undefined = undefined, ) { const runtime = containerRuntime as any; runtime.pendingStateManager = pendingStateManager; runtime.dataStores = getMockDataStores(); - runtime.maxConsecutiveReconnects = maxReconnects ?? runtime.maxConsecutiveReconnects; + runtime.maxConsecutiveReconnects = _maxReconnects ?? runtime.maxConsecutiveReconnects; return runtime as ContainerRuntime; } diff --git a/packages/runtime/container-runtime/src/test/garbageCollection.spec.ts b/packages/runtime/container-runtime/src/test/garbageCollection.spec.ts index a076e30ded34..ed40906442d1 100644 --- a/packages/runtime/container-runtime/src/test/garbageCollection.spec.ts +++ b/packages/runtime/container-runtime/src/test/garbageCollection.spec.ts @@ -99,6 +99,7 @@ describe("Garbage Collection Tests", () => { beforeEach(() => { closeCalled = false; const settings = { "Fluid.GarbageCollection.RunSessionExpiry": "true" }; + // eslint-disable-next-line @typescript-eslint/no-unsafe-return sessionStorageConfigProvider.value.getRawConfig = (name) => settings[name]; }); afterEach(() => { @@ -106,8 +107,8 @@ describe("Garbage Collection Tests", () => { }); it("Session expires for an existing container", async () => { - const metadata: IContainerRuntimeMetadata = - { summaryFormatVersion: 1, message: undefined, sessionExpiryTimeoutMs: 1 } + const metadata: IContainerRuntimeMetadata = + { summaryFormatVersion: 1, message: undefined, sessionExpiryTimeoutMs: 1 }; createGarbageCollector(undefined, undefined, metadata); clock.tick(1); assert(closeCalled, "Close should have been called."); @@ -115,7 +116,7 @@ describe("Garbage Collection Tests", () => { it("Session expires for a new container", async () => { createGarbageCollector(); - clock.tick(defaultSessionExpiryDurationMs); + clock.tick(defaultSessionExpiryDurationMs); assert(closeCalled, "Close should have been called."); }); }); diff --git a/packages/runtime/datastore-definitions/package.json b/packages/runtime/datastore-definitions/package.json index 97b225ce67b8..edf94b59fa26 100644 --- a/packages/runtime/datastore-definitions/package.json +++ b/packages/runtime/datastore-definitions/package.json @@ -49,7 +49,7 @@ "@fluidframework/datastore-definitions-0.55.0": "npm:@fluidframework/datastore-definitions@0.55.0", "@fluidframework/datastore-definitions-0.56.0": "npm:@fluidframework/datastore-definitions@0.56.0", "@fluidframework/datastore-definitions-0.57.0": "npm:@fluidframework/datastore-definitions@0.57.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@typescript-eslint/eslint-plugin": "~5.9.0", diff --git a/packages/runtime/datastore/package.json b/packages/runtime/datastore/package.json index 9dd616871167..29d1fa7f2e7e 100644 --- a/packages/runtime/datastore/package.json +++ b/packages/runtime/datastore/package.json @@ -75,7 +75,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/test-runtime-utils": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", diff --git a/packages/runtime/garbage-collector/package.json b/packages/runtime/garbage-collector/package.json index 526e3fb34e76..f117438b15c3 100644 --- a/packages/runtime/garbage-collector/package.json +++ b/packages/runtime/garbage-collector/package.json @@ -65,7 +65,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/packages/runtime/runtime-definitions/package.json b/packages/runtime/runtime-definitions/package.json index 78cb44c844f4..b362e24743ec 100644 --- a/packages/runtime/runtime-definitions/package.json +++ b/packages/runtime/runtime-definitions/package.json @@ -42,7 +42,7 @@ "devDependencies": { "@fluidframework/build-common": "^0.23.0", "@fluidframework/build-tools": "^0.2.54658", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/runtime-definitions-0.51.1": "npm:@fluidframework/runtime-definitions@0.51.1", "@fluidframework/runtime-definitions-0.52.0": "npm:@fluidframework/runtime-definitions@0.52.0", "@fluidframework/runtime-definitions-0.53.0": "npm:@fluidframework/runtime-definitions@0.53.0", diff --git a/packages/runtime/runtime-utils/package.json b/packages/runtime/runtime-utils/package.json index 0cccc0e63990..8856b5575a47 100644 --- a/packages/runtime/runtime-utils/package.json +++ b/packages/runtime/runtime-utils/package.json @@ -69,7 +69,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/packages/runtime/test-runtime-utils/package.json b/packages/runtime/test-runtime-utils/package.json index 353deb304507..4ea51d85b468 100644 --- a/packages/runtime/test-runtime-utils/package.json +++ b/packages/runtime/test-runtime-utils/package.json @@ -71,7 +71,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/packages/test/functional-tests/package.json b/packages/test/functional-tests/package.json index 17aefb3b48eb..c3416a44c9b8 100644 --- a/packages/test/functional-tests/package.json +++ b/packages/test/functional-tests/package.json @@ -56,7 +56,7 @@ "@fluidframework/common-utils": "^0.32.1", "@fluidframework/container-loader": "^0.58.1000", "@fluidframework/container-runtime": "^0.58.1000", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@fluidframework/protocol-definitions": "^0.1027.0-0", "@fluidframework/sequence": "^0.58.1000", diff --git a/packages/test/local-server-tests/package.json b/packages/test/local-server-tests/package.json index 9b7f093ea89a..d2da983cef8b 100644 --- a/packages/test/local-server-tests/package.json +++ b/packages/test/local-server-tests/package.json @@ -66,7 +66,7 @@ "@fluidframework/driver-base": "^0.58.1000", "@fluidframework/driver-definitions": "^0.45.0-0", "@fluidframework/driver-utils": "^0.58.1000", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/ink": "^0.58.1000", "@fluidframework/local-driver": "^0.58.1000", "@fluidframework/map": "^0.58.1000", diff --git a/packages/test/mocha-test-setup/package.json b/packages/test/mocha-test-setup/package.json index 1b84661c809c..db269761143c 100644 --- a/packages/test/mocha-test-setup/package.json +++ b/packages/test/mocha-test-setup/package.json @@ -56,7 +56,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/packages/test/snapshots/package.json b/packages/test/snapshots/package.json index c7184ddee5ec..ebad7e64c62b 100644 --- a/packages/test/snapshots/package.json +++ b/packages/test/snapshots/package.json @@ -77,7 +77,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/packages/test/test-app-insights-logger/package.json b/packages/test/test-app-insights-logger/package.json index 539440976ddd..2ec33410b781 100644 --- a/packages/test/test-app-insights-logger/package.json +++ b/packages/test/test-app-insights-logger/package.json @@ -53,7 +53,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", "@types/node": "^14.18.0", diff --git a/packages/test/test-driver-definitions/package.json b/packages/test/test-driver-definitions/package.json index 0edd94783fbd..ddaa9db7c65f 100644 --- a/packages/test/test-driver-definitions/package.json +++ b/packages/test/test-driver-definitions/package.json @@ -58,7 +58,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/packages/test/test-drivers/package.json b/packages/test/test-drivers/package.json index 0fc05b1fb2af..a01ba9722dc6 100644 --- a/packages/test/test-drivers/package.json +++ b/packages/test/test-drivers/package.json @@ -73,7 +73,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/packages/test/test-end-to-end-tests/package.json b/packages/test/test-end-to-end-tests/package.json index 132ee4d6ab73..a9eb3867e4cc 100644 --- a/packages/test/test-end-to-end-tests/package.json +++ b/packages/test/test-end-to-end-tests/package.json @@ -115,7 +115,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", "@types/nock": "^9.3.0", diff --git a/packages/test/test-end-to-end-tests/src/test/blobs.spec.ts b/packages/test/test-end-to-end-tests/src/test/blobs.spec.ts index 6e17f3993c4c..48f366465c34 100644 --- a/packages/test/test-end-to-end-tests/src/test/blobs.spec.ts +++ b/packages/test/test-end-to-end-tests/src/test/blobs.spec.ts @@ -231,7 +231,7 @@ describeNoCompat("blobs", (getTestObjectProvider) => { }); itExpects("works in detached container", [ - {"eventName": "fluid:telemetry:Container:ContainerClose", "error": "0x202"} + { eventName: "fluid:telemetry:Container:ContainerClose", error: "0x202" }, ], async function() { const detachedBlobStorage = new MockDetachedBlobStorage(); const loader = provider.makeTestLoader({ ...testContainerConfig, loaderProps: {detachedBlobStorage}}); @@ -282,7 +282,7 @@ describeNoCompat("blobs", (getTestObjectProvider) => { }); itExpects("redirect table saved in snapshot",[ - {"eventName": "fluid:telemetry:Container:ContainerClose","message": "0x202",} + { eventName: "fluid:telemetry:Container:ContainerClose", message: "0x202" }, ], async function() { const detachedBlobStorage = new MockDetachedBlobStorage(); const loader = provider.makeTestLoader({ ...testContainerConfig, loaderProps: {detachedBlobStorage}}); @@ -316,7 +316,7 @@ describeNoCompat("blobs", (getTestObjectProvider) => { }); itExpects("serialize/rehydrate then attach", [ - {"eventName": "fluid:telemetry:Container:ContainerClose", "error": "0x202"} + { eventName: "fluid:telemetry:Container:ContainerClose", error: "0x202" }, ], async function() { const loader = provider.makeTestLoader( {...testContainerConfig, loaderProps: {detachedBlobStorage: new MockDetachedBlobStorage()}}); @@ -345,8 +345,8 @@ describeNoCompat("blobs", (getTestObjectProvider) => { assert.strictEqual(bufferToString(await (attachedDataStore._root.get("my blob")).get(), "utf-8"), text); }); - itExpects("serialize/rehydrate multiple times then attach",[ - {"eventName": "fluid:telemetry:Container:ContainerClose", "error": "0x202"} + itExpects("serialize/rehydrate multiple times then attach", [ + { eventName: "fluid:telemetry:Container:ContainerClose", error: "0x202" }, ], async function() { const loader = provider.makeTestLoader( {...testContainerConfig, loaderProps: {detachedBlobStorage: new MockDetachedBlobStorage()}}); diff --git a/packages/test/test-end-to-end-tests/src/test/codePropsal.spec.ts b/packages/test/test-end-to-end-tests/src/test/codePropsal.spec.ts index 2a22a91370a5..24a4461aab7c 100644 --- a/packages/test/test-end-to-end-tests/src/test/codePropsal.spec.ts +++ b/packages/test/test-end-to-end-tests/src/test/codePropsal.spec.ts @@ -151,7 +151,7 @@ describeNoCompat("CodeProposal.EndToEnd", (getTestObjectProvider) => { itExpects("Code Proposal", [ {eventName:"fluid:telemetry:Container:ContainerClose", error:"Existing context does not satisfy incoming proposal"}, - {eventName:"fluid:telemetry:Container:ContainerClose", error:"Existing context does not satisfy incoming proposal"} + {eventName:"fluid:telemetry:Container:ContainerClose", error:"Existing context does not satisfy incoming proposal"}, ], async () => { const proposal: IFluidCodeDetails = { package: packageV2 }; diff --git a/packages/test/test-end-to-end-tests/src/test/container.spec.ts b/packages/test/test-end-to-end-tests/src/test/container.spec.ts index 8ed7835202a0..4fc0d76b7f6e 100644 --- a/packages/test/test-end-to-end-tests/src/test/container.spec.ts +++ b/packages/test/test-end-to-end-tests/src/test/container.spec.ts @@ -142,7 +142,6 @@ describeNoCompat("Container", (getTestObjectProvider) => { }; const container2 = await loadContainer({ documentServiceFactory: mockFactory }); await waitContainerToCatchUp(container2); - }); it("Raise disconnected event", async () => { diff --git a/packages/test/test-end-to-end-tests/src/test/containerDirtyFlag.spec.ts b/packages/test/test-end-to-end-tests/src/test/containerDirtyFlag.spec.ts index 7e47f8856f72..67c10f42f8bf 100644 --- a/packages/test/test-end-to-end-tests/src/test/containerDirtyFlag.spec.ts +++ b/packages/test/test-end-to-end-tests/src/test/containerDirtyFlag.spec.ts @@ -36,7 +36,6 @@ const testValue = "test value"; type MapCallback = (container: IContainer, dataStore: ITestFluidObject, map: SharedMap) => void | Promise; - async function ensureContainerConnected(container: Container): Promise { if (!container.connected) { return new Promise((resolve) => container.once("connected", () => resolve())); diff --git a/packages/test/test-end-to-end-tests/src/test/deRehydrateContainerTests.spec.ts b/packages/test/test-end-to-end-tests/src/test/deRehydrateContainerTests.spec.ts index 6844e7a6f3e6..f00c2fcb19cd 100644 --- a/packages/test/test-end-to-end-tests/src/test/deRehydrateContainerTests.spec.ts +++ b/packages/test/test-end-to-end-tests/src/test/deRehydrateContainerTests.spec.ts @@ -33,6 +33,7 @@ import { describeFullCompat, itExpects } from "@fluidframework/test-version-util import { getSnapshotTreeFromSerializedContainer, ISnapshotTreeWithBlobContents, +// eslint-disable-next-line import/no-internal-modules } from "@fluidframework/container-loader/dist/utils"; const detachedContainerRefSeqNumber = 0; diff --git a/packages/test/test-end-to-end-tests/src/test/detachedContainerTests.spec.ts b/packages/test/test-end-to-end-tests/src/test/detachedContainerTests.spec.ts index d0a929387af7..1a785756acaa 100644 --- a/packages/test/test-end-to-end-tests/src/test/detachedContainerTests.spec.ts +++ b/packages/test/test-end-to-end-tests/src/test/detachedContainerTests.spec.ts @@ -351,7 +351,7 @@ describeFullCompat("Detached Container", (getTestObjectProvider) => { const comp2 = await requestFluidObject(router, "/"); (container.deltaManager as any).submit = (type, contents, batch, metadata) => { - try{ + try { assert.strictEqual(type, MessageType.Operation, "Op should be an attach op"); assert.strictEqual(contents.type, ContainerMessageType.Attach, "Op should be an attach op"); assert.strictEqual(contents.contents.id, @@ -359,7 +359,7 @@ describeFullCompat("Detached Container", (getTestObjectProvider) => { assert.strictEqual(contents.contents.type, testDataStoreType, "DataStore type should match"); defPromise.resolve(); - }catch(e){ + } catch(e) { defPromise.reject(e); } return 0; @@ -660,7 +660,7 @@ describeNoCompat("Detached Container", (getTestObjectProvider) => { }).timeout(5000); itExpects("Container should be closed on failed attach with non retryable error",[ - {eventName: "fluid:telemetry:Container:ContainerClose", error: "Test Error"} + { eventName: "fluid:telemetry:Container:ContainerClose", error: "Test Error" }, ], async () => { const container = await loader.createDetachedContainer(provider.defaultCodeDetails); diff --git a/packages/test/test-end-to-end-tests/src/test/error.spec.ts b/packages/test/test-end-to-end-tests/src/test/error.spec.ts index 51b85f2a4e6a..ad91327c1e99 100644 --- a/packages/test/test-end-to-end-tests/src/test/error.spec.ts +++ b/packages/test/test-end-to-end-tests/src/test/error.spec.ts @@ -71,19 +71,18 @@ describeNoCompat("Errors Types", (getTestObjectProvider) => { itExpects("GeneralError Test", [ - {eventName: "fluid:telemetry:Container:ContainerClose", error: "false"}, - {eventName: "TestException", errorType: ContainerErrorType.genericError} + {eventName: "fluid:telemetry:Container:ContainerClose", error: ""}, + {eventName: "TestException", errorType: ContainerErrorType.genericError}, ], async () => { const documentServiceFactory = provider.documentServiceFactory; const mockFactory = Object.create(documentServiceFactory) as IDocumentServiceFactory; mockFactory.createDocumentService = async (resolvedUrl) => { const service = await documentServiceFactory.createDocumentService(resolvedUrl); - service.connectToDeltaStream = async () => Promise.reject(false); + service.connectToDeltaStream = async () => { throw new Error(); }; return service; }; await loadContainer({ documentServiceFactory: mockFactory }); - }); function assertCustomPropertySupport(err: any) { diff --git a/packages/test/test-end-to-end-tests/src/test/gc/gcDatastoreAliased.spec.ts b/packages/test/test-end-to-end-tests/src/test/gc/gcDatastoreAliased.spec.ts index cb75d1121212..750087b453c7 100644 --- a/packages/test/test-end-to-end-tests/src/test/gc/gcDatastoreAliased.spec.ts +++ b/packages/test/test-end-to-end-tests/src/test/gc/gcDatastoreAliased.spec.ts @@ -16,7 +16,7 @@ import { describeFullCompat } from "@fluidframework/test-version-utils"; import { IContainerRuntimeOptions, } from "@fluidframework/container-runtime"; -import { IContainerRuntimeBase, } from "@fluidframework/runtime-definitions"; +import { IContainerRuntimeBase } from "@fluidframework/runtime-definitions"; import { TestDataObject } from "./mockSummarizerClient"; import { mockConfigProvider } from "./mockConfigProivder"; @@ -50,7 +50,7 @@ describeFullCompat("GC Data Store Aliased", (getTestObjectProvider) => { [innerRequestHandler], runtimeOptions, ); - + // Enable config provider setting to write GC data at the root. const settings = { "Fluid.GarbageCollection.LogUnknownOutboundRoutes": "true" }; const configProvider = mockConfigProvider(settings); @@ -67,7 +67,7 @@ describeFullCompat("GC Data Store Aliased", (getTestObjectProvider) => { const createContainer = async (): Promise => { return provider.createContainer(runtimeFactory, { configProvider }); - } + }; const loadContainer = async (): Promise => { return provider.loadContainer(runtimeFactory, { configProvider }); }; @@ -94,7 +94,7 @@ describeFullCompat("GC Data Store Aliased", (getTestObjectProvider) => { await provider.ensureSynchronized(); // We run the summary so await this.getInitialSnapshotDetails() is called before the datastore is aliased - // and after the datastore is attached. This sets the isRootDataStore. This should be passing as there is + // and after the datastore is attached. This sets the isRootDataStore. This should be passing as there is // further GC work that will require this test to pass https://github.com/microsoft/FluidFramework/issues/8859 await summarizeOnContainer(container2); @@ -103,15 +103,15 @@ describeFullCompat("GC Data Store Aliased", (getTestObjectProvider) => { const aliasResult1 = await aliasableDataStore1.trySetAlias(alias); assert(aliasResult1 === "Success", `Expected an successful aliasing. Got: ${aliasResult1}`); await provider.ensureSynchronized(); - + // Should be able to retrieve root datastore from remote const containerRuntime2 = mainDataStore2.containerRuntime; const aliasableDataStore2 = await containerRuntime2.getRootDataStore(alias); const aliasedDataStoreResponse2 = await aliasableDataStore2.request({url:"/"}); const aliasedDataStore2 = aliasedDataStoreResponse2.value as TestDataObject; assert(aliasedDataStore2._context.baseSnapshot?.unreferenced !== true, "datastore should be referenced"); - + await summarizeOnContainer(container2); // TODO: Check GC is notified }); -}); \ No newline at end of file +}); diff --git a/packages/test/test-end-to-end-tests/src/test/gc/gcInactiveDataStore.spec.ts b/packages/test/test-end-to-end-tests/src/test/gc/gcInactiveDataStore.spec.ts index e3c99063be71..46d44bf5d908 100644 --- a/packages/test/test-end-to-end-tests/src/test/gc/gcInactiveDataStore.spec.ts +++ b/packages/test/test-end-to-end-tests/src/test/gc/gcInactiveDataStore.spec.ts @@ -101,9 +101,9 @@ describeNoCompat("GC inactive data store tests", (getTestObjectProvider) => { }); itExpects("can generate events when unreferenced data store is accessed after it's inactive", [ - {eventName: changedEvent, timeout: deleteTimeoutMs,}, - {eventName: loadedEvent, timeout: deleteTimeoutMs,}, - {eventName: revivedEvent, timeout: deleteTimeoutMs,}, + { eventName: changedEvent, timeout: deleteTimeoutMs }, + { eventName: loadedEvent, timeout: deleteTimeoutMs }, + { eventName: revivedEvent, timeout: deleteTimeoutMs }, ], async () => { const dataStore1 = await dataObjectFactory.createInstance(defaultDataStore.containerRuntime); defaultDataStore._root.set("dataStore1", dataStore1.handle); diff --git a/packages/test/test-end-to-end-tests/src/test/messageSize.spec.ts b/packages/test/test-end-to-end-tests/src/test/messageSize.spec.ts index 778997f0ad9d..cd05902ccbf8 100644 --- a/packages/test/test-end-to-end-tests/src/test/messageSize.spec.ts +++ b/packages/test/test-end-to-end-tests/src/test/messageSize.spec.ts @@ -50,7 +50,7 @@ describeNoCompat("Message size", (getTestObjectProvider) => { ) => { const configWithFeatureGates = { ...containerConfig, - loaderProps: { configProvider: configProvider(featureGates) } + loaderProps: { configProvider: configProvider(featureGates) }, }; // Create a Container for the first client. @@ -78,7 +78,7 @@ describeNoCompat("Message size", (getTestObjectProvider) => { const value = dataObject2map.get(`key${i}`); assert.strictEqual(value, expected, `Wrong value for key${i}`); } - } + }; const containerError = async (container: IContainer) => new Promise((resolve) => container.once("closed", (error) => { resolve(error); })); diff --git a/packages/test/test-end-to-end-tests/src/test/noDeltaStream.spec.ts b/packages/test/test-end-to-end-tests/src/test/noDeltaStream.spec.ts index d53eb4e73b14..8efc7a5d939e 100644 --- a/packages/test/test-end-to-end-tests/src/test/noDeltaStream.spec.ts +++ b/packages/test/test-end-to-end-tests/src/test/noDeltaStream.spec.ts @@ -159,7 +159,8 @@ describeFullCompat("No Delta stream loading mode testing", (getTestObjectProvide return policies; } - return Reflect.get(target, prop,r); + // eslint-disable-next-line @typescript-eslint/no-unsafe-return + return Reflect.get(target, prop, r); }, }), }; diff --git a/packages/test/test-end-to-end-tests/src/test/rootDatastores.spec.ts b/packages/test/test-end-to-end-tests/src/test/rootDatastores.spec.ts index 6c27ae4836fc..2d059d0725b5 100644 --- a/packages/test/test-end-to-end-tests/src/test/rootDatastores.spec.ts +++ b/packages/test/test-end-to-end-tests/src/test/rootDatastores.spec.ts @@ -42,6 +42,14 @@ describeNoCompat("Named root data stores", (getTestObjectProvider) => { const IdleDetectionTime = 100; const testContainerConfig: ITestContainerConfig = { fluidDataObjectType: DataObjectFactoryType.Test, + runtimeOptions: { + summaryOptions: { + disableSummaries: true, + }, + gcOptions: { + gcAllowed: true, + }, + }, }; const configProvider = ((settings: Record): IConfigProviderBase => { @@ -57,7 +65,7 @@ describeNoCompat("Named root data stores", (getTestObjectProvider) => { provider.reset(); const configWithFeatureGates = { ...containerConfig, - loaderProps: { configProvider: configProvider(featureGates) } + loaderProps: { configProvider: configProvider(featureGates) }, }; container1 = await provider.makeTestContainer(configWithFeatureGates); dataObject1 = await requestFluidObject(container1, "/"); @@ -78,7 +86,7 @@ describeNoCompat("Named root data stores", (getTestObjectProvider) => { const allDataCorruption = async (containers: IContainer[]) => Promise.all( containers.map(async (c) => new Promise((resolve) => c.once("closed", (error) => { resolve(error?.errorType === ContainerErrorType.dataCorruptionError); - })))).then((all)=>!all.includes(false)); + })))).then((all) => !all.includes(false)); const runtimeOf = (dataObject: ITestFluidObject): IContainerRuntime => dataObject.context.containerRuntime as IContainerRuntime; @@ -109,7 +117,7 @@ describeNoCompat("Named root data stores", (getTestObjectProvider) => { afterEach(async () => reset()); itExpects("Root datastore creation fails at attach op", [ - {eventName: "fluid:telemetry:Container:ContainerClose", error: "Duplicate DataStore created with existing id"} + { eventName: "fluid:telemetry:Container:ContainerClose", error: "Duplicate DataStore created with existing id" }, ], async () => { const dataCorruption = anyDataCorruption([container1, container2]); // Isolate inbound communication @@ -126,8 +134,8 @@ describeNoCompat("Named root data stores", (getTestObjectProvider) => { assert(await dataCorruption); }); - itExpects("Root datastore creation with props fails at attach op",[ - {eventName: "fluid:telemetry:Container:ContainerClose", error: "Duplicate DataStore created with existing id"} + itExpects("Root datastore creation with props fails at attach op", [ + { eventName: "fluid:telemetry:Container:ContainerClose", error: "Duplicate DataStore created with existing id" }, ], async () => { const dataCorruption = anyDataCorruption([container1, container2]); // Isolate inbound communication @@ -144,8 +152,8 @@ describeNoCompat("Named root data stores", (getTestObjectProvider) => { assert(await dataCorruption); }); - itExpects("Root datastore creation with the same id breaks container",[ - {eventName: "fluid:telemetry:Container:ContainerClose", error: "Duplicate DataStore created with existing id"} + itExpects("Root datastore creation with the same id breaks container", [ + { eventName: "fluid:telemetry:Container:ContainerClose", error: "Duplicate DataStore created with existing id" }, ], async () => { const dataCorruption = anyDataCorruption([container1, container2]); await createRootDataStore(dataObject1, "2"); @@ -154,8 +162,8 @@ describeNoCompat("Named root data stores", (getTestObjectProvider) => { assert(await dataCorruption); }); - itExpects("Root datastore creation with the same id and legacy API breaks container",[ - {eventName: "fluid:telemetry:Container:ContainerClose", error: "Duplicate DataStore created with existing id"} + itExpects("Root datastore creation with the same id and legacy API breaks container", [ + { eventName: "fluid:telemetry:Container:ContainerClose", error: "Duplicate DataStore created with existing id" }, ], async () => { const dataCorruption = anyDataCorruption([container1, container2]); await createRootDataStore(dataObject1, "2"); @@ -320,7 +328,6 @@ describeNoCompat("Named root data stores", (getTestObjectProvider) => { const aliasResult2 = await ds2.trySetAlias(alias); const aliasResult3 = await ds2.trySetAlias(alias + alias); - assert.equal(aliasResult1, "Success"); assert.equal(aliasResult2, "Conflict"); assert.equal(aliasResult3, "AlreadyAliased"); @@ -328,9 +335,8 @@ describeNoCompat("Named root data stores", (getTestObjectProvider) => { assert.ok(await getRootDataStore(dataObject1, alias)); }); - itExpects("Creating a root data store with an existing alias as an id breaks the container",[ - {eventName: "fluid:telemetry:Container:ContainerClose", error: "Duplicate DataStore created with existing id"}, - {eventName: "fluid:telemetry:Container:ContainerClose", error: "Duplicate DataStore created with existing id"}, + itExpects("Creating a root data store with an existing alias as an id breaks the container", [ + { eventName: "fluid:telemetry:Container:ContainerClose", error: "Duplicate DataStore created with existing id" }, ], async () => { const dataCorruption = anyDataCorruption([container1, container2]); const ds1 = await runtimeOf(dataObject1).createDataStore(packageName); @@ -348,9 +354,8 @@ describeNoCompat("Named root data stores", (getTestObjectProvider) => { }); itExpects("Receiving a bad alias message breaks the container", [ - {eventName: "fluid:telemetry:Container:ContainerClose", error: "malformedDataStoreAliasMessage"}, - {eventName: "fluid:telemetry:Container:ContainerClose", error: "malformedDataStoreAliasMessage"}, - {eventName: "fluid:telemetry:Container:ContainerClose", error: "malformedDataStoreAliasMessage"}, + { eventName: "fluid:telemetry:Container:ContainerClose", error: "malformedDataStoreAliasMessage" }, + { eventName: "fluid:telemetry:Container:ContainerClose", error: "malformedDataStoreAliasMessage" }, ], async () => { const dataCorruption = allDataCorruption([container1, container2]); await corruptedAliasOp(runtimeOf(dataObject1), alias); @@ -368,131 +373,116 @@ describeNoCompat("Named root data stores", (getTestObjectProvider) => { assert.equal(aliasResult2, "Conflict"); await provider.ensureSynchronized(); - const container3 = await provider.loadTestContainer(testContainerConfig); const dataObject3 = await requestFluidObject(container3, "/"); assert.ok(await getRootDataStore(dataObject3, alias)); }); it("Assign an alias which has previously been assigned as id by the legacy API, " + - "different containers", async () => { - await createRootDataStore(dataObject1, alias); - const ds2 = await runtimeOf(dataObject1).createDataStore(packageName); - const aliasResult2 = await ds2.trySetAlias(alias); - assert.equal(aliasResult2, "Conflict"); + "different containers", async () => { + await createRootDataStore(dataObject1, alias); + const ds2 = await runtimeOf(dataObject1).createDataStore(packageName); + const aliasResult2 = await ds2.trySetAlias(alias); + assert.equal(aliasResult2, "Conflict"); - assert.ok(await getRootDataStore(dataObject2, alias)); - }); + assert.ok(await getRootDataStore(dataObject2, alias)); + }); it("Assign multiple data stores to the same alias, first write wins, " + - "different containers from snapshot", async () => { - - await setupContainers({ - ... testContainerConfig, - runtimeOptions: { - summaryOptions: { - generateSummaries: true, - initialSummarizerDelayMs: 10, - summaryConfigOverrides: { - idleTime: IdleDetectionTime, - maxTime: IdleDetectionTime * 12, + "different containers from snapshot", async () => { + await setupContainers({ + ...testContainerConfig, + runtimeOptions: { + summaryOptions: { + generateSummaries: true, + initialSummarizerDelayMs: 10, + summaryConfigOverrides: { + idleTime: IdleDetectionTime, + maxTime: IdleDetectionTime * 12, + }, + }, + gcOptions: { + gcAllowed: true, }, }, - gcOptions: { - gcAllowed: true, - }, - }, - }); - - // andre4i: Move this into test utils or something. Same as for other - // flavors of this function across the end to end tests - const waitForSummary = async ( - testObjectProvider: ITestObjectProvider, - container: IContainer, - summaryCollection: SummaryCollection, - ): Promise => { - await testObjectProvider.ensureSynchronized(); - const ackedSummary: IAckedSummary = - await summaryCollection.waitSummaryAck(container.deltaManager.lastSequenceNumber); - return ackedSummary.summaryAck.contents.handle; - }; - - const sc = new SummaryCollection(container1.deltaManager, new TelemetryNullLogger()); - const ds1 = await runtimeOf(dataObject1).createDataStore(packageName); - const ds2 = await runtimeOf(dataObject2).createDataStore(packageName); - - const aliasResult1 = await ds1.trySetAlias(alias); - const aliasResult2 = await ds2.trySetAlias(alias); - - assert.equal(aliasResult1, "Success"); - assert.equal(aliasResult2, "Conflict"); - - await provider.ensureSynchronized(); - const version = await waitForSummary(provider, container1, sc); + }); - const container3 = await provider.loadTestContainer( - testContainerConfig, - { - [LoaderHeader.version]: version, - }, // requestHeader - ); - const dataObject3 = await requestFluidObject(container3, "/"); - const ds3 = await runtimeOf(dataObject3).createDataStore(packageName); - const aliasResult3 = await ds3.trySetAlias(alias); + // andre4i: Move this into test utils or something. Same as for other + // flavors of this function across the end to end tests + const waitForSummary = async ( + testObjectProvider: ITestObjectProvider, + container: IContainer, + summaryCollection: SummaryCollection, + ): Promise => { + await testObjectProvider.ensureSynchronized(); + const ackedSummary: IAckedSummary = + await summaryCollection.waitSummaryAck(container.deltaManager.lastSequenceNumber); + return ackedSummary.summaryAck.contents.handle; + }; + + const sc = new SummaryCollection(container1.deltaManager, new TelemetryNullLogger()); + const ds1 = await runtimeOf(dataObject1).createDataStore(packageName); + const ds2 = await runtimeOf(dataObject2).createDataStore(packageName); + + const aliasResult1 = await ds1.trySetAlias(alias); + const aliasResult2 = await ds2.trySetAlias(alias); + assert.equal(aliasResult1, "Success"); + assert.equal(aliasResult2, "Conflict"); - assert.equal(aliasResult3, "Conflict"); - assert.ok(await getRootDataStore(dataObject3, alias)); - }); + await provider.ensureSynchronized(); + const version = await waitForSummary(provider, container1, sc); + + const container3 = await provider.loadTestContainer( + testContainerConfig, + { + [LoaderHeader.version]: version, + }, // requestHeader + ); + const dataObject3 = await requestFluidObject(container3, "/"); + const ds3 = await runtimeOf(dataObject3).createDataStore(packageName); + const aliasResult3 = await ds3.trySetAlias(alias); + + assert.equal(aliasResult3, "Conflict"); + assert.ok(await getRootDataStore(dataObject3, alias)); + }); /** * Aliasing datastores summarized before the alias op is sent and after the attach op is sent * does not cause a datastore corruption issue - * + * * This test validates a bug where the rootiness of a datastore was not set to true in the * above scenario. */ it("Aliasing a bound datastore marks it as root correctly", async () => { - await setupContainers({ - ... testContainerConfig, - runtimeOptions: { - summaryOptions: { - disableSummaries: true, - }, - gcOptions: { - gcAllowed: true, - }, - }, - }); - const containerRuntime1 = runtimeOf(dataObject1); const aliasableDataStore1 = await containerRuntime1.createDataStore(packageName); - const aliasedDataStoreResponse1 = await aliasableDataStore1.request({url:"/"}); + const aliasedDataStoreResponse1 = await aliasableDataStore1.request({ url: "/" }); const aliasedDataStore1 = aliasedDataStoreResponse1.value as ITestFluidObject; // Casting any to repro a race condition where bindToContext is called before summarization, // but aliasing happens afterwards (aliasableDataStore1 as any).fluidDataStoreChannel.bindToContext(); await provider.ensureSynchronized(); - + const containerRuntime2 = runtimeOf(dataObject2) as ContainerRuntime; let callFailed = false; - try{ + try { // This executes getInitialSnapshotDetails, a LazyPromise, before the alias op is sent to update // the isRootDataStore property in the dataStoreContext await containerRuntime2.getRootDataStore(aliasedDataStore1.runtime.id); - }catch(e){ + } catch (e) { callFailed = true; } assert(callFailed, "Expected getRootDataStore to fail as the datastore is not yet a root datastore"); - + // Alias a datastore - const alias = "alias"; - const aliasResult1 = await aliasableDataStore1.trySetAlias(alias); + const _alias = "alias"; + const aliasResult1 = await aliasableDataStore1.trySetAlias(_alias); assert(aliasResult1 === "Success", `Expected an successful aliasing. Got: ${aliasResult1}`); await provider.ensureSynchronized(); - + // Should be able to retrieve root datastore from remote - assert.doesNotThrow(async () => - await containerRuntime2.getRootDataStore(alias), "An aliased datastore should be a root datastore"); + assert.doesNotThrow(async () => + containerRuntime2.getRootDataStore(_alias), "An aliased datastore should be a root datastore"); }); }); }); diff --git a/packages/test/test-end-to-end-tests/src/test/sharedStringLoading.spec.ts b/packages/test/test-end-to-end-tests/src/test/sharedStringLoading.spec.ts index c761d5d9d0a3..8f74dc9fe1e4 100644 --- a/packages/test/test-end-to-end-tests/src/test/sharedStringLoading.spec.ts +++ b/packages/test/test-end-to-end-tests/src/test/sharedStringLoading.spec.ts @@ -31,12 +31,12 @@ describeNoCompat("SharedString", (getTestObjectProvider) => { itExpects( "Failure to Load in Shared String", [ - {eventName: "fluid:telemetry:FluidDataStoreRuntime:RemoteChannelContext:ChannelStorageBlobError"}, + { eventName: "fluid:telemetry:FluidDataStoreRuntime:RemoteChannelContext:ChannelStorageBlobError" }, // eslint-disable-next-line max-len - {eventName: "fluid:telemetry:FluidDataStoreRuntime:SharedSegmentSequence.MergeTreeClient:SnapshotLoader:CatchupOpsLoadFailure"}, - {eventName: "fluid:telemetry:FluidDataStoreRuntime:SequenceLoadFailed"}, - {eventName: "fluid:telemetry:FluidDataStoreRuntime:GetChannelFailedInRequest"}, - {eventName: "TestException"} + { eventName: "fluid:telemetry:FluidDataStoreRuntime:SharedSegmentSequence.MergeTreeClient:SnapshotLoader:CatchupOpsLoadFailure" }, + { eventName: "fluid:telemetry:FluidDataStoreRuntime:SequenceLoadFailed" }, + { eventName: "fluid:telemetry:FluidDataStoreRuntime:GetChannelFailedInRequest" }, + { eventName: "TestException" }, ], async () => { const stringId = "sharedStringKey"; diff --git a/packages/test/test-end-to-end-tests/src/test/stashedOps.spec.ts b/packages/test/test-end-to-end-tests/src/test/stashedOps.spec.ts index 84167e484132..6911e2ff8485 100644 --- a/packages/test/test-end-to-end-tests/src/test/stashedOps.spec.ts +++ b/packages/test/test-end-to-end-tests/src/test/stashedOps.spec.ts @@ -41,7 +41,7 @@ const ensureContainerConnected = async (container: IContainer) => { if (!container.connected) { return new Promise((resolve) => container.once("connected", () => resolve())); } -} +}; type MapCallback = (container: IContainer, dataStore: ITestFluidObject, map: SharedMap) => void | Promise; diff --git a/packages/test/test-pairwise-generator/package.json b/packages/test/test-pairwise-generator/package.json index cdbdf24700cb..767092cc7780 100644 --- a/packages/test/test-pairwise-generator/package.json +++ b/packages/test/test-pairwise-generator/package.json @@ -51,7 +51,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/packages/test/test-service-load/package.json b/packages/test/test-service-load/package.json index 8bf13772c9c4..f5b7bfc55723 100644 --- a/packages/test/test-service-load/package.json +++ b/packages/test/test-service-load/package.json @@ -89,7 +89,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/packages/test/test-utils/package.json b/packages/test/test-utils/package.json index 4c7eaebb0ff5..9463f364209e 100644 --- a/packages/test/test-utils/package.json +++ b/packages/test/test-utils/package.json @@ -76,7 +76,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/diff": "^3.5.1", diff --git a/packages/test/test-utils/src/retry.ts b/packages/test/test-utils/src/retry.ts index fc05f60413fa..2c81178b9469 100644 --- a/packages/test/test-utils/src/retry.ts +++ b/packages/test/test-utils/src/retry.ts @@ -21,7 +21,7 @@ const retry = async ( } return Promise.resolve(defaultValue); -} +}; /** * Simple retry mechanism with linear back off to call diff --git a/packages/test/test-utils/src/testObjectProvider.ts b/packages/test/test-utils/src/testObjectProvider.ts index 98975671b4a6..45a4583e6913 100644 --- a/packages/test/test-utils/src/testObjectProvider.ts +++ b/packages/test/test-utils/src/testObjectProvider.ts @@ -128,61 +128,61 @@ function getDocumentIdStrategy(type?: TestDriverTypes): IDocumentIdStrategy { * At any point you call reportAndClearTrackedEvents which will provide all unexpected errors, and * any expected events that have not occurred. */ -export class EventAndErrorTrackingLogger extends TelemetryLogger{ - constructor(private readonly baseLogger: ITelemetryBaseLogger){ +export class EventAndErrorTrackingLogger extends TelemetryLogger { + constructor(private readonly baseLogger: ITelemetryBaseLogger) { super(); } - private readonly expectedEvents: ({index:number, event: ITelemetryGenericEvent | undefined} | undefined)[] = [] - private readonly unexpectedErrors: ITelemetryBaseEvent[] =[]; + private readonly expectedEvents: ({index: number, event: ITelemetryGenericEvent | undefined} | undefined)[] = []; + private readonly unexpectedErrors: ITelemetryBaseEvent[] = []; - public registerExpectedEvent(... orderedExpectedEvents: ITelemetryGenericEvent[]){ - if(this.expectedEvents.length !== 0){ + public registerExpectedEvent(... orderedExpectedEvents: ITelemetryGenericEvent[]) { + if(this.expectedEvents.length !== 0) { // we don't have to error here. just no reason not to. given the events must be // ordered it could be tricky to figure out problems around multiple registrations. throw new Error( "Expected events already registered.\n" - + "Call reportAndClearTrackedEvents to clear them before registering more") + + "Call reportAndClearTrackedEvents to clear them before registering more"); } this.expectedEvents.push(... orderedExpectedEvents.map((event,index)=>({index, event}))); } send(event: ITelemetryBaseEvent): void { const ee = this.expectedEvents[0]?.event; - if(ee?.eventName === event.eventName){ + if(ee?.eventName === event.eventName) { let matches = true; - for(const key of Object.keys(ee)){ - if(ee[key] !== event[key]){ + for(const key of Object.keys(ee)) { + if(ee[key] !== event[key]) { matches = false; break; } } - if(matches){ + if(matches) { // we found an expected event // so remove it from the list of expected events // and if it is an error, change it to generic // this helps keep our telemetry clear of // expected errors. this.expectedEvents.shift(); - if(event.category === "error"){ + if(event.category === "error") { event.category = "generic"; } } } - if(event.category === "error"){ + if(event.category === "error") { this.unexpectedErrors.push(event); } - this.baseLogger.send(event) + this.baseLogger.send(event); } - public reportAndClearTrackedEvents(){ + public reportAndClearTrackedEvents() { const expectedNotFound = this.expectedEvents.splice(0, this.expectedEvents.length); const unexpectedErrors = this.unexpectedErrors.splice(0, this.unexpectedErrors.length); return { expectedNotFound, unexpectedErrors, - } + }; } } @@ -378,8 +378,8 @@ export class TestObjectProvider implements ITestObjectProvider { this._documentIdStrategy.reset(); const logError = getUnexpectedLogErrorException(this._logger); if(logError) { - throw logError - }; + throw logError; + } this._logger = undefined; this._documentCreated = false; } @@ -393,17 +393,17 @@ export class TestObjectProvider implements ITestObjectProvider { } } -export function getUnexpectedLogErrorException(logger: EventAndErrorTrackingLogger | undefined, prefix?: string){ - if(logger === undefined){ +export function getUnexpectedLogErrorException(logger: EventAndErrorTrackingLogger | undefined, prefix?: string) { + if(logger === undefined) { return; } const results = logger.reportAndClearTrackedEvents(); - if(results.unexpectedErrors.length > 0){ + if(results.unexpectedErrors.length > 0) { return new Error( `${prefix ?? ""}Unexpected Errors in Logs:\n${JSON.stringify(results.unexpectedErrors, undefined, 2)}`); } - if(results.expectedNotFound.length > 0){ + if(results.expectedNotFound.length > 0) { return new Error( `${prefix ?? ""}Expected Events not found:\n${JSON.stringify(results.expectedNotFound, undefined, 2)}`); } -} \ No newline at end of file +} diff --git a/packages/test/test-version-utils/package.json b/packages/test/test-version-utils/package.json index 4894cbc63a89..809ea2027d37 100644 --- a/packages/test/test-version-utils/package.json +++ b/packages/test/test-version-utils/package.json @@ -76,7 +76,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", "@types/nock": "^9.3.0", diff --git a/packages/test/test-version-utils/src/compatConfig.ts b/packages/test/test-version-utils/src/compatConfig.ts index 779ca6e490c2..f8c75f2a055d 100644 --- a/packages/test/test-version-utils/src/compatConfig.ts +++ b/packages/test/test-version-utils/src/compatConfig.ts @@ -2,6 +2,7 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ +import { Lazy } from "@fluidframework/common-utils"; import { ensurePackageInstalled } from "./testApi"; import { pkgVersion } from "./packageVersion"; import { @@ -14,7 +15,6 @@ import { baseVersion, reinstall, } from "./compatOptions"; -import { Lazy } from "@fluidframework/common-utils"; /* * Generate configuration combinations for a particular compat version @@ -126,9 +126,7 @@ const genLTSConfig = (compatVersion: number | string): CompatConfig[] => { ]; }; - -export const configList = new Lazy(()=>{ - +export const configList = new Lazy(() => { // set it in the env for parallel workers if (compatKind) { process.env.fluid__test__compatKind = JSON.stringify(compatKind); @@ -141,26 +139,26 @@ export const configList = new Lazy(()=>{ process.env.fluid__test__tenantIndex = tenantIndex.toString(); process.env.fluid__test__baseVersion = baseVersion; - let configList: CompatConfig[] = []; + let _configList: CompatConfig[] = []; if (!compatVersions || compatVersions.length === 0) { defaultVersions.forEach((value) => { - configList.push(...genConfig(value)); + _configList.push(...genConfig(value)); }); LTSVersions.forEach((value) => { - configList.push(...genLTSConfig(value)); + _configList.push(...genLTSConfig(value)); }); } else { compatVersions.forEach((value) => { if (value === "LTS") { LTSVersions.forEach((lts) => { - configList.push(...genLTSConfig(lts)); + _configList.push(...genLTSConfig(lts)); }); } else { const num = parseInt(value, 10); if (num.toString() === value) { - configList.push(...genConfig(num)); + _configList.push(...genConfig(num)); } else { - configList.push(...genConfig(value)); + _configList.push(...genConfig(value)); } } }); @@ -168,12 +166,11 @@ export const configList = new Lazy(()=>{ if (compatKind !== undefined) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - configList = configList.filter((value) => compatKind!.includes(value.kind)); + _configList = _configList.filter((value) => compatKind!.includes(value.kind)); } - return configList; + return _configList; }); - /* * Mocha start up to ensure legacy versions are installed */ diff --git a/packages/test/test-version-utils/src/describeCompat.ts b/packages/test/test-version-utils/src/describeCompat.ts index 25ff48da5e4d..60fe521ae821 100644 --- a/packages/test/test-version-utils/src/describeCompat.ts +++ b/packages/test/test-version-utils/src/describeCompat.ts @@ -15,17 +15,17 @@ function createCompatSuite( tests: (this: Mocha.Suite, provider: () => ITestObjectProvider) => void, compatFilter?: CompatKind[], ) { - return function (this: Mocha.Suite){ + return function(this: Mocha.Suite) { let configs = configList.value; if (compatFilter !== undefined) { configs = configs.filter((value) => compatFilter.includes(value.kind)); } for (const config of configs) { - describe(config.name, function () { + describe(config.name, function() { let provider: TestObjectProvider; let resetAfterEach: boolean; - before(async function () { + before(async function() { provider = await getVersionedTestObjectProvider( baseVersion, config.loader, @@ -48,7 +48,8 @@ function createCompatSuite( } return provider; }); - afterEach(function (done:Mocha.Done) { + // eslint-disable-next-line prefer-arrow-callback + afterEach(function(done: Mocha.Done) { done(getUnexpectedLogErrorException(provider.logger, "Use itExpects to specify expected errors. ")); if (resetAfterEach) { provider.reset(); @@ -59,16 +60,16 @@ function createCompatSuite( }; } -export type DescribeCompatSuite= +export type DescribeCompatSuite = (name: string, tests: ( this: Mocha.Suite, provider: (resetAfterEach?: boolean) => ITestObjectProvider) => void - ) => Mocha.Suite | void + ) => Mocha.Suite | void; export type DescribeCompat = DescribeCompatSuite & Record<"skip" | "only" | "noCompat", DescribeCompatSuite>; -function createCompatDescribe(compatFilter?: CompatKind[]): DescribeCompat{ +function createCompatDescribe(compatFilter?: CompatKind[]): DescribeCompat { const d: DescribeCompat = (name, tests) => describe(name, createCompatSuite(tests, compatFilter)); d.skip = (name, tests) => describe.skip(name, createCompatSuite(tests, compatFilter)); @@ -77,8 +78,8 @@ function createCompatDescribe(compatFilter?: CompatKind[]): DescribeCompat{ return d; } -export const describeNoCompat: DescribeCompat = createCompatDescribe([CompatKind.None]) +export const describeNoCompat: DescribeCompat = createCompatDescribe([CompatKind.None]); export const describeLoaderCompat: DescribeCompat = createCompatDescribe([CompatKind.None, CompatKind.Loader]); -export const describeFullCompat: DescribeCompat = createCompatDescribe(); \ No newline at end of file +export const describeFullCompat: DescribeCompat = createCompatDescribe(); diff --git a/packages/test/test-version-utils/src/index.ts b/packages/test/test-version-utils/src/index.ts index 4c7e7b8356d2..22700276b06d 100644 --- a/packages/test/test-version-utils/src/index.ts +++ b/packages/test/test-version-utils/src/index.ts @@ -2,10 +2,9 @@ * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ -export {mochaGlobalSetup} from "./compatConfig" +export { mochaGlobalSetup } from "./compatConfig"; export * from "./compatUtils"; export * from "./packageVersion"; export * from "./testApi"; export * from "./itExpects"; export * from "./describeCompat"; - diff --git a/packages/test/test-version-utils/src/itExpects.ts b/packages/test/test-version-utils/src/itExpects.ts index 88fccc8c2d19..d9d7627e8d9c 100644 --- a/packages/test/test-version-utils/src/itExpects.ts +++ b/packages/test/test-version-utils/src/itExpects.ts @@ -5,42 +5,42 @@ import { getUnexpectedLogErrorException, TestObjectProvider } from "@fluidframework/test-utils"; import { ITelemetryGenericEvent } from "@fluidframework/common-definitions"; +// eslint-disable-next-line import/no-extraneous-dependencies import { Context } from "mocha"; - -function createExpectsTest(orderedExpectedEvents: ITelemetryGenericEvent[], test: Mocha.AsyncFunc){ - return async function (this:Context){ +function createExpectsTest(orderedExpectedEvents: ITelemetryGenericEvent[], test: Mocha.AsyncFunc) { + return async function(this: Context) { const provider: TestObjectProvider | undefined = this.__fluidTestProvider; - if(provider === undefined){ + if (provider === undefined) { throw new Error("Expected __fluidTestProvider on this"); } - try{ + try { provider.logger.registerExpectedEvent(... orderedExpectedEvents); await test.bind(this)(); - }catch(error){ + } catch(error) { // only use TestException if the event is provided. // it must be last, as the events are ordered, so all other events must come first - if(orderedExpectedEvents[orderedExpectedEvents.length -1]?.eventName === "TestException"){ - provider.logger.sendErrorEvent({eventName:"TestException"},error) - }else{ + if (orderedExpectedEvents[orderedExpectedEvents.length - 1]?.eventName === "TestException") { + provider.logger.sendErrorEvent({ eventName:"TestException" }, error); + } else { throw error; } } const err = getUnexpectedLogErrorException(provider.logger); - if(err !== undefined){ + if (err !== undefined) { throw err; } }; } export type ExpectsTest = - (name: string, orderedExpectedEvents: ITelemetryGenericEvent[], test: Mocha.AsyncFunc) => Mocha.Test + (name: string, orderedExpectedEvents: ITelemetryGenericEvent[], test: Mocha.AsyncFunc) => Mocha.Test; /** * Similar to mocha's it function, but allow specifying expected events. * That must occur during the execution of the test. */ -export const itExpects: ExpectsTest & Record<"only" |"skip", ExpectsTest> = +export const itExpects: ExpectsTest & Record<"only" | "skip", ExpectsTest> = (name: string, orderedExpectedEvents: ITelemetryGenericEvent[], test: Mocha.AsyncFunc): Mocha.Test => it(name, createExpectsTest(orderedExpectedEvents, test)); diff --git a/packages/tools/fetch-tool/package.json b/packages/tools/fetch-tool/package.json index e9a1bc78f243..39943ce45c16 100644 --- a/packages/tools/fetch-tool/package.json +++ b/packages/tools/fetch-tool/package.json @@ -46,7 +46,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", "@typescript-eslint/eslint-plugin": "~5.9.0", diff --git a/packages/tools/merge-tree-client-replay/package.json b/packages/tools/merge-tree-client-replay/package.json index 69a8255873a1..01f16c9728fd 100644 --- a/packages/tools/merge-tree-client-replay/package.json +++ b/packages/tools/merge-tree-client-replay/package.json @@ -40,7 +40,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", diff --git a/packages/tools/replay-tool/package.json b/packages/tools/replay-tool/package.json index 72d5591d994a..0cb07672d2e1 100644 --- a/packages/tools/replay-tool/package.json +++ b/packages/tools/replay-tool/package.json @@ -57,7 +57,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", diff --git a/packages/tools/webpack-fluid-loader/package.json b/packages/tools/webpack-fluid-loader/package.json index a3dcb81dea72..ddb017705621 100644 --- a/packages/tools/webpack-fluid-loader/package.json +++ b/packages/tools/webpack-fluid-loader/package.json @@ -88,7 +88,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", "@types/express": "^4.11.0", diff --git a/packages/utils/odsp-doclib-utils/package.json b/packages/utils/odsp-doclib-utils/package.json index 4dc9da07712b..078dc56cc661 100644 --- a/packages/utils/odsp-doclib-utils/package.json +++ b/packages/utils/odsp-doclib-utils/package.json @@ -64,7 +64,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", diff --git a/packages/utils/telemetry-utils/package.json b/packages/utils/telemetry-utils/package.json index 3642d28bd4de..8199979dd30b 100644 --- a/packages/utils/telemetry-utils/package.json +++ b/packages/utils/telemetry-utils/package.json @@ -67,7 +67,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/packages/utils/telemetry-utils/src/errorLogging.ts b/packages/utils/telemetry-utils/src/errorLogging.ts index 73a0e3af5c6b..f484f9f1f79b 100644 --- a/packages/utils/telemetry-utils/src/errorLogging.ts +++ b/packages/utils/telemetry-utils/src/errorLogging.ts @@ -327,7 +327,7 @@ export class LoggingError extends Error implements ILoggingError, Pick { const errorType = "someErrorType"; assert(!isFluidError( - Object.assign(new LoggingError("hello"), { errorType, _errorInstanceId: undefined }) + Object.assign(new LoggingError("hello"), { errorType, _errorInstanceId: undefined }), )); assert(isFluidError( - Object.assign(new LoggingError("hello"), { errorType }) + Object.assign(new LoggingError("hello"), { errorType }), )); }); // I copied the old version of isFluidError here, it depends on fluidErrorCode. @@ -775,10 +775,10 @@ describe("Error Discovery", () => { const errorType = "someErrorType"; assert(!isFluidError_old( - Object.assign(new LoggingError("hello"), { errorType, _errorInstanceId: undefined }) + Object.assign(new LoggingError("hello"), { errorType, _errorInstanceId: undefined }), )); assert(isFluidError_old( - Object.assign(new LoggingError("hello"), { errorType }) + Object.assign(new LoggingError("hello"), { errorType }), )); }); }); diff --git a/packages/utils/tool-utils/package.json b/packages/utils/tool-utils/package.json index 6275eeb17d2f..7f454e79dc3b 100644 --- a/packages/utils/tool-utils/package.json +++ b/packages/utils/tool-utils/package.json @@ -67,7 +67,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.58.1000", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/server/azure-local-service/package-lock.json b/server/azure-local-service/package-lock.json index b4a55a331946..33dcfc6dbc05 100644 --- a/server/azure-local-service/package-lock.json +++ b/server/azure-local-service/package-lock.json @@ -90,9 +90,9 @@ } }, "@fluidframework/eslint-config-fluid": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.26.0.tgz", - "integrity": "sha512-odm+o74yEZU3hFqBag6jPtdLZxv2ponFNGGe/1ZzHw/wVDDDy4G07Kjbai+76t4TH2+dTOWaTjWOFt9h68bU1A==", + "version": "0.27.0-51301", + "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.27.0-51301.tgz", + "integrity": "sha512-P/+BCF8vAwoSBUrkTYizg5iKaRnE0NNEVieur1Lp1HjzvRwKr/UYgVd6EEZ2hZ7SlpB2zMCcGuuccm6uX1A/ow==", "dev": true, "requires": { "@rushstack/eslint-config": "^2.5.1", diff --git a/server/azure-local-service/package.json b/server/azure-local-service/package.json index da25719ac2fd..fb91e54e0087 100644 --- a/server/azure-local-service/package.json +++ b/server/azure-local-service/package.json @@ -32,7 +32,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@typescript-eslint/eslint-plugin": "~5.9.0", diff --git a/server/gitrest/package-lock.json b/server/gitrest/package-lock.json index 357480d16a4f..49b6f9cc035a 100644 --- a/server/gitrest/package-lock.json +++ b/server/gitrest/package-lock.json @@ -327,9 +327,9 @@ } }, "@fluidframework/eslint-config-fluid": { - "version": "0.26.0-50282", - "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.26.0-50282.tgz", - "integrity": "sha512-2fLJ0LNPCuBuAPTRs8NVMK28IcQQtL/z7KYF9nbNcFDTkaMfKsVfFKsBOLIuSPyAimK/S/mCl4639+OCcNcBqg==", + "version": "0.27.0-51301", + "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.27.0-51301.tgz", + "integrity": "sha512-P/+BCF8vAwoSBUrkTYizg5iKaRnE0NNEVieur1Lp1HjzvRwKr/UYgVd6EEZ2hZ7SlpB2zMCcGuuccm6uX1A/ow==", "dev": true, "requires": { "@rushstack/eslint-config": "^2.5.1", diff --git a/server/gitrest/package.json b/server/gitrest/package.json index 33e83f442bd6..806d3b7fef78 100644 --- a/server/gitrest/package.json +++ b/server/gitrest/package.json @@ -46,7 +46,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0-0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/async": "^3.2.6", "@types/cors": "^2.8.4", diff --git a/server/gitrest/src/app.ts b/server/gitrest/src/app.ts index 8ec08af195dc..21d129c1b6f8 100644 --- a/server/gitrest/src/app.ts +++ b/server/gitrest/src/app.ts @@ -8,7 +8,7 @@ import cors from "cors"; import express, { Express } from "express"; import morgan from "morgan"; import nconf from "nconf"; -import split = require("split"); +import split from "split"; import winston from "winston"; import { bindCorrelationId } from "@fluidframework/server-services-utils"; import { IExternalStorageManager } from "./externalStorageManager"; diff --git a/server/gitrest/src/routes/git/blobs.ts b/server/gitrest/src/routes/git/blobs.ts index ba71c84c7d37..175df295bf09 100644 --- a/server/gitrest/src/routes/git/blobs.ts +++ b/server/gitrest/src/routes/git/blobs.ts @@ -16,7 +16,7 @@ export function create(store: nconf.Provider, repoManagerFactory: IRepositoryMan const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => repoManager.createBlob( + ).then(async (repoManager) => repoManager.createBlob( request.body as ICreateBlobParams, )); @@ -30,7 +30,7 @@ export function create(store: nconf.Provider, repoManagerFactory: IRepositoryMan const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => repoManager.getBlob( + ).then(async (repoManager) => repoManager.getBlob( request.params.sha, )); diff --git a/server/gitrest/src/routes/git/commits.ts b/server/gitrest/src/routes/git/commits.ts index c8c3a313653f..9cd0856f9c3a 100644 --- a/server/gitrest/src/routes/git/commits.ts +++ b/server/gitrest/src/routes/git/commits.ts @@ -18,7 +18,7 @@ export function create(store: nconf.Provider, repoManagerFactory: IRepositoryMan const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => repoManager.createCommit(request.body as ICreateCommitParams)); + ).then(async (repoManager) => repoManager.createCommit(request.body as ICreateCommitParams)); handleResponse(resultP, response, 201); }); @@ -27,7 +27,7 @@ export function create(store: nconf.Provider, repoManagerFactory: IRepositoryMan const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => repoManager.getCommit(request.params.sha)); + ).then(async (repoManager) => repoManager.getCommit(request.params.sha)); handleResponse(resultP, response); }); diff --git a/server/gitrest/src/routes/git/refs.ts b/server/gitrest/src/routes/git/refs.ts index fbb8938afa2b..a6ce93f860ea 100644 --- a/server/gitrest/src/routes/git/refs.ts +++ b/server/gitrest/src/routes/git/refs.ts @@ -30,7 +30,7 @@ export function create( const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => repoManager.getRefs()); + ).then(async (repoManager) => repoManager.getRefs()); handleResponse(resultP, response); }); @@ -38,7 +38,7 @@ export function create( const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => repoManager.getRef( + ).then(async (repoManager) => repoManager.getRef( getRefId(request.params[0]), getExternalWriterParams(request.query?.config as string), )); @@ -50,7 +50,7 @@ export function create( const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => repoManager.createRef( + ).then(async (repoManager) => repoManager.createRef( createRefParams, createRefParams.config, )); @@ -62,7 +62,7 @@ export function create( const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => repoManager.patchRef( + ).then(async (repoManager) => repoManager.patchRef( getRefId(request.params[0]), patchRefParams, patchRefParams.config, @@ -74,7 +74,7 @@ export function create( const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => repoManager.deleteRef(getRefId(request.params[0]))); + ).then(async (repoManager) => repoManager.deleteRef(getRefId(request.params[0]))); handleResponse(resultP, response, 204); }); return router; diff --git a/server/gitrest/src/routes/git/tags.ts b/server/gitrest/src/routes/git/tags.ts index ebbe22c46c23..02fd9f46c27d 100644 --- a/server/gitrest/src/routes/git/tags.ts +++ b/server/gitrest/src/routes/git/tags.ts @@ -18,7 +18,7 @@ export function create(store: nconf.Provider, repoManagerFactory: IRepositoryMan const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => repoManager.createTag(request.body as ICreateTagParams)); + ).then(async (repoManager) => repoManager.createTag(request.body as ICreateTagParams)); handleResponse(resultP, response, 201); }); @@ -27,7 +27,7 @@ export function create(store: nconf.Provider, repoManagerFactory: IRepositoryMan const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => repoManager.getTag(request.params[0])); + ).then(async (repoManager) => repoManager.getTag(request.params[0])); handleResponse(resultP, response); }); diff --git a/server/gitrest/src/routes/git/trees.ts b/server/gitrest/src/routes/git/trees.ts index 8597b7781202..14725abc861f 100644 --- a/server/gitrest/src/routes/git/trees.ts +++ b/server/gitrest/src/routes/git/trees.ts @@ -16,7 +16,7 @@ export function create(store: nconf.Provider, repoManagerFactory: IRepositoryMan const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => repoManager.createTree(request.body as ICreateTreeParams)); + ).then(async (repoManager) => repoManager.createTree(request.body as ICreateTreeParams)); handleResponse(resultP, response, 201); }); @@ -25,7 +25,7 @@ export function create(store: nconf.Provider, repoManagerFactory: IRepositoryMan const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => repoManager.getTree(request.params.sha, request.query.recursive === "1")); + ).then(async (repoManager) => repoManager.getTree(request.params.sha, request.query.recursive === "1")); handleResponse(resultP, response); }); diff --git a/server/gitrest/src/routes/index.ts b/server/gitrest/src/routes/index.ts index 1cf96fd7202a..3f98e5b4b128 100644 --- a/server/gitrest/src/routes/index.ts +++ b/server/gitrest/src/routes/index.ts @@ -6,6 +6,7 @@ import { Router } from "express"; import nconf from "nconf"; import { IRepositoryManagerFactory } from "../utils"; +/* eslint-disable import/no-internal-modules */ import * as blobs from "./git/blobs"; import * as commits from "./git/commits"; import * as refs from "./git/refs"; @@ -14,6 +15,7 @@ import * as tags from "./git/tags"; import * as trees from "./git/trees"; import * as repositoryCommits from "./repository/commits"; import * as contents from "./repository/contents"; +/* eslint-enable import/no-internal-modules */ import * as summaries from "./summaries"; export interface IRoutes { diff --git a/server/gitrest/src/routes/repository/commits.ts b/server/gitrest/src/routes/repository/commits.ts index 2bb11e4a777a..71808d2b297d 100644 --- a/server/gitrest/src/routes/repository/commits.ts +++ b/server/gitrest/src/routes/repository/commits.ts @@ -21,7 +21,7 @@ export function create(store: nconf.Provider, repoManagerFactory: IRepositoryMan const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => repoManager.getCommits( + ).then(async (repoManager) => repoManager.getCommits( request.query.sha as string, Number(request.query.count as string), getExternalWriterParams(request.query?.config as string), diff --git a/server/gitrest/src/routes/repository/contents.ts b/server/gitrest/src/routes/repository/contents.ts index 7d2b6f561f9b..739610f6a5f3 100644 --- a/server/gitrest/src/routes/repository/contents.ts +++ b/server/gitrest/src/routes/repository/contents.ts @@ -15,7 +15,7 @@ export function create(store: nconf.Provider, repoManagerFactory: IRepositoryMan const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => repoManager.getContent( + ).then(async (repoManager) => repoManager.getContent( request.query.ref as string, request.params[0], )); diff --git a/server/gitrest/src/routes/summaries.ts b/server/gitrest/src/routes/summaries.ts index fb5ab61bd47f..6392c355447d 100644 --- a/server/gitrest/src/routes/summaries.ts +++ b/server/gitrest/src/routes/summaries.ts @@ -173,7 +173,7 @@ export class WholeSummaryWriteGitManager { `refs/heads/${this.documentId}`, { enabled: this.externalStorageEnabled }, ).catch(() => undefined); - let commitParams: ICreateCommitParams + let commitParams: ICreateCommitParams; if (!existingRef && payload.sequenceNumber === 0) { // Create new document commitParams = { @@ -209,7 +209,7 @@ export class WholeSummaryWriteGitManager { force: true, sha: commit.sha, }, - { enabled: this.externalStorageEnabled } + { enabled: this.externalStorageEnabled }, ); } else { await this.repoManager.createRef( @@ -369,7 +369,7 @@ export function create( const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => getSummary( + ).then(async (repoManager) => getSummary( repoManager, request.params.sha, documentId, @@ -392,7 +392,7 @@ export function create( const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => createSummary( + ).then(async (repoManager) => createSummary( repoManager, wholeSummaryPayload, documentId, @@ -410,7 +410,7 @@ export function create( const resultP = repoManagerFactory.open( request.params.owner, request.params.repo, - ).then((repoManager) => deleteSummary(repoManager, softDelete)); + ).then(async (repoManager) => deleteSummary(repoManager, softDelete)); handleResponse(resultP, response, 204); }); diff --git a/server/gitrest/src/runner.ts b/server/gitrest/src/runner.ts index 6dd0c2ccce60..0eb933f845a2 100644 --- a/server/gitrest/src/runner.ts +++ b/server/gitrest/src/runner.ts @@ -21,7 +21,7 @@ export class GitrestRunner implements IRunner { private readonly externalStorageManager: IExternalStorageManager) { } - public start(): Promise { + public async start(): Promise { this.runningDeferred = new Deferred(); // Create the gitrest app const gitrest = app.create(this.config, this.externalStorageManager); @@ -38,7 +38,7 @@ export class GitrestRunner implements IRunner { return this.runningDeferred.promise; } - public stop(): Promise { + public async stop(): Promise { // Close the underlying server and then resolve the runner once closed this.server.close().then( () => { diff --git a/server/gitrest/src/test/routes.spec.ts b/server/gitrest/src/test/routes.spec.ts index 8892fd9d0e60..31b8c746fac1 100644 --- a/server/gitrest/src/test/routes.spec.ts +++ b/server/gitrest/src/test/routes.spec.ts @@ -21,8 +21,8 @@ import sillyname from "sillyname"; import request from "supertest"; import * as app from "../app"; import { ExternalStorageManager } from "../externalStorageManager"; -import * as testUtils from "./utils"; import { NodegitRepositoryManagerFactory } from "../utils"; +import * as testUtils from "./utils"; // TODO: (issue logged): replace email & name const commitEmail = "kurtb@microsoft.com"; diff --git a/server/historian/lerna-package-lock.json b/server/historian/lerna-package-lock.json index e1970546c883..baa9c781bf07 100644 --- a/server/historian/lerna-package-lock.json +++ b/server/historian/lerna-package-lock.json @@ -399,9 +399,9 @@ } }, "@fluidframework/eslint-config-fluid": { - "version": "0.26.0-50282", - "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.26.0-50282.tgz", - "integrity": "sha512-2fLJ0LNPCuBuAPTRs8NVMK28IcQQtL/z7KYF9nbNcFDTkaMfKsVfFKsBOLIuSPyAimK/S/mCl4639+OCcNcBqg==", + "version": "0.27.0-51301", + "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.27.0-51301.tgz", + "integrity": "sha512-P/+BCF8vAwoSBUrkTYizg5iKaRnE0NNEVieur1Lp1HjzvRwKr/UYgVd6EEZ2hZ7SlpB2zMCcGuuccm6uX1A/ow==", "dev": true, "requires": { "@rushstack/eslint-config": "^2.5.1", diff --git a/server/historian/package-lock.json b/server/historian/package-lock.json index 0f85fb450fb8..cfcf6fe2876e 100644 --- a/server/historian/package-lock.json +++ b/server/historian/package-lock.json @@ -366,9 +366,9 @@ } }, "@fluidframework/eslint-config-fluid": { - "version": "0.26.0-50282", - "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.26.0-50282.tgz", - "integrity": "sha512-2fLJ0LNPCuBuAPTRs8NVMK28IcQQtL/z7KYF9nbNcFDTkaMfKsVfFKsBOLIuSPyAimK/S/mCl4639+OCcNcBqg==", + "version": "0.27.0-51301", + "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.27.0-51301.tgz", + "integrity": "sha512-P/+BCF8vAwoSBUrkTYizg5iKaRnE0NNEVieur1Lp1HjzvRwKr/UYgVd6EEZ2hZ7SlpB2zMCcGuuccm6uX1A/ow==", "dev": true, "requires": { "@rushstack/eslint-config": "^2.5.1", diff --git a/server/historian/package.json b/server/historian/package.json index 7ae14a7d11e7..4a2cf3b323c9 100644 --- a/server/historian/package.json +++ b/server/historian/package.json @@ -45,7 +45,7 @@ }, "devDependencies": { "@fluidframework/build-tools": "^0.2.54658", - "@fluidframework/eslint-config-fluid": "^0.26.0-0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/compression": "0.0.36", "@types/cors": "^2.8.4", diff --git a/server/historian/packages/historian-base/package.json b/server/historian/packages/historian-base/package.json index 1115c6ec0413..8df8c29de491 100644 --- a/server/historian/packages/historian-base/package.json +++ b/server/historian/packages/historian-base/package.json @@ -50,7 +50,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0-0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/server-test-utils": "^0.1035.0-55212", "@rushstack/eslint-config": "^2.5.1", "@types/compression": "0.0.36", diff --git a/server/historian/packages/historian-base/src/services/restGitService.ts b/server/historian/packages/historian-base/src/services/restGitService.ts index 6d98ce74317a..fe3ebad2df41 100644 --- a/server/historian/packages/historian-base/src/services/restGitService.ts +++ b/server/historian/packages/historian-base/src/services/restGitService.ts @@ -4,8 +4,8 @@ */ import { AsyncLocalStorage } from "async_hooks"; -import type { AxiosRequestHeaders } from "axios"; import * as querystring from "querystring"; +import type { AxiosRequestHeaders } from "axios"; import * as git from "@fluidframework/gitresources"; import { IGetRefParamsExternal, @@ -58,7 +58,7 @@ export class RestGitService { private readonly documentId: string, private readonly cache?: ICache, private readonly asyncLocalStorage?: AsyncLocalStorage, - private readonly storageName? : string) { + private readonly storageName?: string) { let defaultHeaders: AxiosRequestHeaders; if (storageName !== undefined) { defaultHeaders = { diff --git a/server/historian/packages/historian/package.json b/server/historian/packages/historian/package.json index 014f62a5952a..9362f1bb5b85 100644 --- a/server/historian/packages/historian/package.json +++ b/server/historian/packages/historian/package.json @@ -37,7 +37,7 @@ "winston": "^3.3.3" }, "devDependencies": { - "@fluidframework/eslint-config-fluid": "^0.26.0-0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/compression": "0.0.36", "@types/cors": "^2.8.4", diff --git a/server/routerlicious/lerna-package-lock.json b/server/routerlicious/lerna-package-lock.json index ef670243508f..e7b9d1e3e245 100644 --- a/server/routerlicious/lerna-package-lock.json +++ b/server/routerlicious/lerna-package-lock.json @@ -449,9 +449,9 @@ } }, "@fluidframework/eslint-config-fluid": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.26.0.tgz", - "integrity": "sha512-odm+o74yEZU3hFqBag6jPtdLZxv2ponFNGGe/1ZzHw/wVDDDy4G07Kjbai+76t4TH2+dTOWaTjWOFt9h68bU1A==", + "version": "0.27.0-51301", + "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.27.0-51301.tgz", + "integrity": "sha512-P/+BCF8vAwoSBUrkTYizg5iKaRnE0NNEVieur1Lp1HjzvRwKr/UYgVd6EEZ2hZ7SlpB2zMCcGuuccm6uX1A/ow==", "requires": { "@rushstack/eslint-config": "^2.5.1", "@rushstack/eslint-patch": "^1.1.0", diff --git a/server/routerlicious/packages/gitresources/package.json b/server/routerlicious/packages/gitresources/package.json index f1accc386a18..62167a531e44 100644 --- a/server/routerlicious/packages/gitresources/package.json +++ b/server/routerlicious/packages/gitresources/package.json @@ -24,7 +24,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@typescript-eslint/eslint-plugin": "~5.9.0", "@typescript-eslint/parser": "~5.9.0", diff --git a/server/routerlicious/packages/kafka-orderer/package.json b/server/routerlicious/packages/kafka-orderer/package.json index 154882498c92..a08450496ea6 100644 --- a/server/routerlicious/packages/kafka-orderer/package.json +++ b/server/routerlicious/packages/kafka-orderer/package.json @@ -28,7 +28,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/node": "^14.18.0", "@typescript-eslint/eslint-plugin": "~5.9.0", diff --git a/server/routerlicious/packages/lambdas-driver/package.json b/server/routerlicious/packages/lambdas-driver/package.json index 98adfbeaf018..a9eb8b8182e9 100644 --- a/server/routerlicious/packages/lambdas-driver/package.json +++ b/server/routerlicious/packages/lambdas-driver/package.json @@ -56,7 +56,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/server-test-utils": "^0.1035.1000", "@rushstack/eslint-config": "^2.5.1", "@types/async": "^3.2.6", diff --git a/server/routerlicious/packages/lambdas/package.json b/server/routerlicious/packages/lambdas/package.json index 2d0820f061f0..e7befeb9d6ae 100644 --- a/server/routerlicious/packages/lambdas/package.json +++ b/server/routerlicious/packages/lambdas/package.json @@ -69,7 +69,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/server-test-utils": "^0.1035.1000", "@rushstack/eslint-config": "^2.5.1", "@types/async": "^3.2.6", diff --git a/server/routerlicious/packages/lambdas/src/scribe/summaryReader.ts b/server/routerlicious/packages/lambdas/src/scribe/summaryReader.ts index 6464397cdc34..c3051295d496 100644 --- a/server/routerlicious/packages/lambdas/src/scribe/summaryReader.ts +++ b/server/routerlicious/packages/lambdas/src/scribe/summaryReader.ts @@ -47,7 +47,7 @@ export class SummaryReader implements ISummaryReader { shouldRetryNetworkError, this.maxRetriesOnError); const wholeFlatSummary = await requestWithRetry( - async() => this.summaryStorage.getSummary(existingRef.object.sha), + async () => this.summaryStorage.getSummary(existingRef.object.sha), "readWholeSummary_getSummary", this.lumberProperties, shouldRetryNetworkError, @@ -110,32 +110,32 @@ export class SummaryReader implements ISummaryReader { this.maxRetriesOnError); const [attributesContent, scribeContent, deliContent, opsContent] = await Promise.all([ requestWithRetry( - async() => this.summaryStorage.getContent(existingRef.object.sha, ".protocol/attributes"), + async () => this.summaryStorage.getContent(existingRef.object.sha, ".protocol/attributes"), "readSummary_getProtocolAttributesContent", this.lumberProperties, shouldRetryNetworkError, - this.maxRetriesOnError + this.maxRetriesOnError, ).catch(() => undefined), requestWithRetry( - async() => this.summaryStorage.getContent(existingRef.object.sha, ".serviceProtocol/scribe"), + async () => this.summaryStorage.getContent(existingRef.object.sha, ".serviceProtocol/scribe"), "readSummary_getServiceProtocolScribeContent", this.lumberProperties, shouldRetryNetworkError, - this.maxRetriesOnError + this.maxRetriesOnError, ).catch(() => undefined), requestWithRetry( - async() => this.summaryStorage.getContent(existingRef.object.sha, ".serviceProtocol/deli"), + async () => this.summaryStorage.getContent(existingRef.object.sha, ".serviceProtocol/deli"), "readSummary_getServiceProtocolDeliContent", this.lumberProperties, shouldRetryNetworkError, - this.maxRetriesOnError + this.maxRetriesOnError, ).catch(() => undefined), requestWithRetry( - async() => this.summaryStorage.getContent(existingRef.object.sha, ".logTail/logTail"), + async () => this.summaryStorage.getContent(existingRef.object.sha, ".logTail/logTail"), "readSummary_getLogTailContent", this.lumberProperties, shouldRetryNetworkError, - this.maxRetriesOnError + this.maxRetriesOnError, ).catch(() => undefined), ]); diff --git a/server/routerlicious/packages/local-server/package.json b/server/routerlicious/packages/local-server/package.json index dac591be2b18..9ba71ce21ab3 100644 --- a/server/routerlicious/packages/local-server/package.json +++ b/server/routerlicious/packages/local-server/package.json @@ -66,7 +66,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/jsrsasign": "^8.0.8", "@types/mocha": "^8.2.2", diff --git a/server/routerlicious/packages/memory-orderer/package.json b/server/routerlicious/packages/memory-orderer/package.json index 5b3d7d7148a9..6336dd95f17c 100644 --- a/server/routerlicious/packages/memory-orderer/package.json +++ b/server/routerlicious/packages/memory-orderer/package.json @@ -72,7 +72,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", "@types/uuid": "^8.3.0", diff --git a/server/routerlicious/packages/protocol-base/package.json b/server/routerlicious/packages/protocol-base/package.json index 26b36843e74e..7b73ed7735ec 100644 --- a/server/routerlicious/packages/protocol-base/package.json +++ b/server/routerlicious/packages/protocol-base/package.json @@ -61,7 +61,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/assert": "^1.5.1", diff --git a/server/routerlicious/packages/routerlicious-base/package.json b/server/routerlicious/packages/routerlicious-base/package.json index c76a5db5aaa4..b88337e21462 100644 --- a/server/routerlicious/packages/routerlicious-base/package.json +++ b/server/routerlicious/packages/routerlicious-base/package.json @@ -83,7 +83,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/server-local-server": "^0.1035.1000", "@fluidframework/server-test-utils": "^0.1035.1000", "@rushstack/eslint-config": "^2.5.1", diff --git a/server/routerlicious/packages/routerlicious/package.json b/server/routerlicious/packages/routerlicious/package.json index d8b43601c749..9184e7a9916e 100644 --- a/server/routerlicious/packages/routerlicious/package.json +++ b/server/routerlicious/packages/routerlicious/package.json @@ -61,7 +61,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/server-local-server": "^0.1035.1000", "@fluidframework/server-test-utils": "^0.1035.1000", "@rushstack/eslint-config": "^2.5.1", diff --git a/server/routerlicious/packages/services-client/package.json b/server/routerlicious/packages/services-client/package.json index 482d0fdba322..de881a97b4bf 100644 --- a/server/routerlicious/packages/services-client/package.json +++ b/server/routerlicious/packages/services-client/package.json @@ -68,7 +68,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", "@types/debug": "^4.1.5", diff --git a/server/routerlicious/packages/services-core/package.json b/server/routerlicious/packages/services-core/package.json index 999f9b4816c3..28e4a03422b6 100644 --- a/server/routerlicious/packages/services-core/package.json +++ b/server/routerlicious/packages/services-core/package.json @@ -36,7 +36,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@typescript-eslint/eslint-plugin": "~5.9.0", "@typescript-eslint/parser": "~5.9.0", diff --git a/server/routerlicious/packages/services-ordering-kafkanode/package.json b/server/routerlicious/packages/services-ordering-kafkanode/package.json index e8a1876e42d1..a06181205272 100644 --- a/server/routerlicious/packages/services-ordering-kafkanode/package.json +++ b/server/routerlicious/packages/services-ordering-kafkanode/package.json @@ -32,7 +32,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/server-test-utils": "^0.1035.1000", "@rushstack/eslint-config": "^2.5.1", "@types/debug": "^4.1.5", diff --git a/server/routerlicious/packages/services-ordering-rdkafka/package.json b/server/routerlicious/packages/services-ordering-rdkafka/package.json index 4de47a196a24..5d3688ba0085 100644 --- a/server/routerlicious/packages/services-ordering-rdkafka/package.json +++ b/server/routerlicious/packages/services-ordering-rdkafka/package.json @@ -32,7 +32,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/server-test-utils": "^0.1035.1000", "@rushstack/eslint-config": "^2.5.1", "@types/amqplib": "^0.5.17", diff --git a/server/routerlicious/packages/services-ordering-rdkafka/src/rdkafkaProducer.ts b/server/routerlicious/packages/services-ordering-rdkafka/src/rdkafkaProducer.ts index a374d1269f29..394a3b85f6be 100644 --- a/server/routerlicious/packages/services-ordering-rdkafka/src/rdkafkaProducer.ts +++ b/server/routerlicious/packages/services-ordering-rdkafka/src/rdkafkaProducer.ts @@ -291,7 +291,6 @@ export class RdkafkaProducer extends RdkafkaBase implements IProducer { tenantId: boxcar.tenantId, documentId: boxcar.documentId, }); - } else { boxcar.deferred.resolve(); this.emit("produced", boxcarMessage, offset, message.length); @@ -309,7 +308,6 @@ export class RdkafkaProducer extends RdkafkaBase implements IProducer { .then(boxcar.deferred.resolve) .catch(boxcar.deferred.reject); } - } catch (ex) { // produce can throw if the outgoing message queue is full boxcar.deferred.reject(ex); diff --git a/server/routerlicious/packages/services-ordering-zookeeper/package.json b/server/routerlicious/packages/services-ordering-zookeeper/package.json index bf479f2fa417..bab8a19e9bd6 100644 --- a/server/routerlicious/packages/services-ordering-zookeeper/package.json +++ b/server/routerlicious/packages/services-ordering-zookeeper/package.json @@ -29,7 +29,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/server-test-utils": "^0.1035.1000", "@rushstack/eslint-config": "^2.5.1", "@types/debug": "^4.1.5", diff --git a/server/routerlicious/packages/services-shared/package.json b/server/routerlicious/packages/services-shared/package.json index af4151e51e85..8bc8a2f4af17 100644 --- a/server/routerlicious/packages/services-shared/package.json +++ b/server/routerlicious/packages/services-shared/package.json @@ -69,7 +69,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/debug": "^4.1.5", "@types/formidable": "1.2.3", diff --git a/server/routerlicious/packages/services-telemetry/package.json b/server/routerlicious/packages/services-telemetry/package.json index 6c5fe0aa240c..cf09a6fd123a 100644 --- a/server/routerlicious/packages/services-telemetry/package.json +++ b/server/routerlicious/packages/services-telemetry/package.json @@ -56,7 +56,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/mocha": "^8.2.2", "@types/node": "^14.18.0", diff --git a/server/routerlicious/packages/services-utils/package.json b/server/routerlicious/packages/services-utils/package.json index fe24ded0e28c..fa18b0dcc3f3 100644 --- a/server/routerlicious/packages/services-utils/package.json +++ b/server/routerlicious/packages/services-utils/package.json @@ -64,7 +64,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/server-test-utils": "^0.1035.1000", "@rushstack/eslint-config": "^2.5.1", "@types/debug": "^4.1.5", diff --git a/server/routerlicious/packages/services/package.json b/server/routerlicious/packages/services/package.json index 82912f70a9be..fbf361c2079e 100644 --- a/server/routerlicious/packages/services/package.json +++ b/server/routerlicious/packages/services/package.json @@ -70,7 +70,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/server-test-utils": "^0.1035.1000", "@rushstack/eslint-config": "^2.5.1", "@types/amqplib": "^0.5.17", diff --git a/server/routerlicious/packages/test-utils/package.json b/server/routerlicious/packages/test-utils/package.json index aa5e7e35391f..71e4aec814d1 100644 --- a/server/routerlicious/packages/test-utils/package.json +++ b/server/routerlicious/packages/test-utils/package.json @@ -60,7 +60,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@rushstack/eslint-config": "^2.5.1", "@types/lodash": "^4.14.118", "@types/mocha": "^8.2.2", diff --git a/server/tinylicious/package-lock.json b/server/tinylicious/package-lock.json index a60c656d5ded..614b05dbcd8f 100644 --- a/server/tinylicious/package-lock.json +++ b/server/tinylicious/package-lock.json @@ -97,9 +97,9 @@ } }, "@fluidframework/eslint-config-fluid": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.26.0.tgz", - "integrity": "sha512-odm+o74yEZU3hFqBag6jPtdLZxv2ponFNGGe/1ZzHw/wVDDDy4G07Kjbai+76t4TH2+dTOWaTjWOFt9h68bU1A==", + "version": "0.27.0-51301", + "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.27.0-51301.tgz", + "integrity": "sha512-P/+BCF8vAwoSBUrkTYizg5iKaRnE0NNEVieur1Lp1HjzvRwKr/UYgVd6EEZ2hZ7SlpB2zMCcGuuccm6uX1A/ow==", "dev": true, "requires": { "@rushstack/eslint-config": "^2.5.1", diff --git a/server/tinylicious/package.json b/server/tinylicious/package.json index 6f10e62ae758..fa6a4d8135cc 100644 --- a/server/tinylicious/package.json +++ b/server/tinylicious/package.json @@ -68,7 +68,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.27.0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/tools/benchmark/package-lock.json b/tools/benchmark/package-lock.json index a9e16902175f..482aca1b6f3a 100644 --- a/tools/benchmark/package-lock.json +++ b/tools/benchmark/package-lock.json @@ -412,9 +412,9 @@ } }, "@fluidframework/eslint-config-fluid": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.26.0.tgz", - "integrity": "sha512-odm+o74yEZU3hFqBag6jPtdLZxv2ponFNGGe/1ZzHw/wVDDDy4G07Kjbai+76t4TH2+dTOWaTjWOFt9h68bU1A==", + "version": "0.27.0-51301", + "resolved": "https://registry.npmjs.org/@fluidframework/eslint-config-fluid/-/eslint-config-fluid-0.27.0-51301.tgz", + "integrity": "sha512-P/+BCF8vAwoSBUrkTYizg5iKaRnE0NNEVieur1Lp1HjzvRwKr/UYgVd6EEZ2hZ7SlpB2zMCcGuuccm6uX1A/ow==", "dev": true, "requires": { "@rushstack/eslint-config": "^2.5.1", diff --git a/tools/benchmark/package.json b/tools/benchmark/package.json index f6814178a248..d381f8bf7744 100644 --- a/tools/benchmark/package.json +++ b/tools/benchmark/package.json @@ -35,7 +35,7 @@ }, "devDependencies": { "@fluidframework/build-common": "^0.23.0", - "@fluidframework/eslint-config-fluid": "^0.26.0", + "@fluidframework/eslint-config-fluid": "^0.27.0-0", "@fluidframework/mocha-test-setup": "^0.41.0", "@microsoft/api-extractor": "^7.16.1", "@rushstack/eslint-config": "^2.5.1", diff --git a/tools/build-tools/src/fluidBuild/tasks/leaf/lintTasks.ts b/tools/build-tools/src/fluidBuild/tasks/leaf/lintTasks.ts index cc3c8f08b523..e0cac33e1185 100644 --- a/tools/build-tools/src/fluidBuild/tasks/leaf/lintTasks.ts +++ b/tools/build-tools/src/fluidBuild/tasks/leaf/lintTasks.ts @@ -74,7 +74,11 @@ export class EsLintTask extends LintBaseTask { throw new Error(`Unable to parse options from ${this.configFileFullPath}. ${e}`) } if (config.parserOptions?.project) { - for (const tsConfigPath of config.parserOptions?.project) { + // parserOptions.project is type string | string[] + const projectArray = typeof config.parserOptions.project === "string" + ? [config.parserOptions.project] + : config.parserOptions.project; + for (const tsConfigPath of projectArray) { this.addTscTask(dependentTasks, { tsConfig: this.getPackageFileFullPath(tsConfigPath) }); } } diff --git a/tools/pipelines/build-docs.yml b/tools/pipelines/build-docs.yml index 04101573b92d..d0e45b668b70 100644 --- a/tools/pipelines/build-docs.yml +++ b/tools/pipelines/build-docs.yml @@ -15,6 +15,13 @@ parameters: - default - skip - force + - name: deployEnvironment + displayName: Static web app environment to deploy to + type: string + default: new + values: + - new + - old - name: guardianAssetRetentionOverride displayName: Guardian Asset Retention Override (default = based on branch) type: string @@ -67,6 +74,11 @@ variables: )}} - name: arrow.releasedtoproduction value: eq(variables.shouldDeploy, true) + - name: deploymentToken + ${{ if eq( parameters['deployEnvironment'], 'new' ) }}: + value: "$(FLUID_WEBSITE_TORUS_API_TOKEN)" + ${{ if eq( parameters['deployEnvironment'], 'old') }}: + value: "$(AZURE_STATIC_WEB_APPS_API_TOKEN)" # no PR triggers trigger: @@ -103,39 +115,48 @@ resources: source: server-routerlicious stages: -- stage: check - displayName: Checks - pool: Small +- stage: build + displayName: 'Build website' + dependsOn: [] # run in parallel jobs: - - job: - displayName: Component Detection - steps: - - script: | - echo SourceBranchName: ${{ variables['Build.SourceBranchName'] }} - echo BASE_URL: $(BASE_URL) - echo RELEASE_VERSION: $(RELEASE_VERSION) - echo MAIN_BRANCH_VERSION: $(MAIN_BRANCH_VERSION) - echo N1_VERSION: $(N1_VERSION) - echo releasePipeline ${{ variables.releasePipeline }} - echo latestPipeline ${{ variables.latestPipeline }} - echo n1Pipeline ${{ variables.n1Pipeline }} - echo repoToTrigger ${{ variables.repoToTrigger }} - displayName: 'Show Variables' - - task: ComponentGovernanceComponentDetection@0 + - job: debug_variables + displayName: Show Variables + dependsOn: [] # run in parallel + pool: Small + steps: + - checkout: none + - script: | + echo SourceBranchName: ${{ variables['Build.SourceBranchName'] }} + echo BASE_URL: $(BASE_URL) + echo RELEASE_VERSION: $(RELEASE_VERSION) + echo MAIN_BRANCH_VERSION: $(MAIN_BRANCH_VERSION) + echo N1_VERSION: $(N1_VERSION) + echo releasePipeline ${{ variables.releasePipeline }} + echo latestPipeline ${{ variables.latestPipeline }} + echo n1Pipeline ${{ variables.n1Pipeline }} + echo repoToTrigger ${{ variables.repoToTrigger }} + echo shouldDeploy ${{ variables.shouldDeploy }} + echo shouldRetainGuardianAssets ${{ variables.shouldRetainGuardianAssets }} + displayName: Show Variables + + - job: component_detection displayName: Component Detection - inputs: - sourceScanPath: docs - verbosity: Verbose - scanType: Register - alertWarningLevel: High + dependsOn: [] # run in parallel + pool: Small + steps: + - task: ComponentGovernanceComponentDetection@0 + displayName: Component Detection + inputs: + sourceScanPath: docs + verbosity: Verbose + scanType: Register + alertWarningLevel: High -- stage: json - displayName: 'Combine API Extractor JSON' - dependsOn: [] # run in parallel - jobs: - deployment: upload_json - displayName: 'Upload combined api-extractor JSON' + displayName: 'Combine api-extractor JSON' + dependsOn: [] # run in parallel environment: 'fluid-docs-env' + pool: Small strategy: runOnce: deploy: @@ -146,117 +167,147 @@ stages: STORAGE_KEY: $(STORAGE_KEY) uploadAsLatest: ${{ variables.isMainOrNext }} -- stage: site_build - displayName: 'Build website' - dependsOn: json - jobs: - job: build_site - condition: in(stageDependencies.json.upload_json.result, 'Succeeded', 'SucceededWithIssues') - pool: - vmImage: windows-latest + displayName: 'Build website' + dependsOn: upload_json + pool: Large steps: - - checkout: self - submodules: false - clean: true + - checkout: self + submodules: false + clean: true + + - task: DownloadPipelineArtifact@2 + displayName: 'Copy api-extractor JSON to staging folder' + inputs: + source: current + artifact: api-extractor-combined + path: '$(Build.SourcesDirectory)/_api-extractor-temp/doc-models' - - download: current - artifact: api-extractor-combined + - task: UseNode@1 + displayName: 'Use Node 14.x' + inputs: + version: 14.x - - task: CopyFiles@2 - displayName: 'Copy api-extractor JSON to staging folder' - inputs: - contents: '$(Pipeline.Workspace)/api-extractor-combined/**' - targetFolder: '$(Build.SourcesDirectory)/_api-extractor-temp' + - task: Npm@1 + displayName: npm ci + inputs: + command: 'custom' + workingDir: '$(Build.SourcesDirectory)/docs' + customCommand: 'ci' - - task: UseNode@1 - displayName: 'Use Node 14.x' - inputs: - version: 14.x + - task: Npm@1 + displayName: npm run build + inputs: + command: 'custom' + workingDir: '$(Build.SourcesDirectory)/docs' + customCommand: 'run build' - # BEGIN Secure development tasks - - task: UseDotNet@2 - displayName: 'Use .NET Core 3.x' - condition: succeededOrFailed() - inputs: - packageType: sdk - version: 3.x + - task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0 + displayName: 'Generate SBOM' + inputs: + BuildDropPath: '$(Build.SourcesDirectory)/docs/public' + PackageName: 'fluidframework-docs' + PackageVersion: '$(Build.BuildId)' - - task: securedevelopmentteam.vss-secure-development-tools.build-task-eslint.ESLint@1 - displayName: 'Run ESLint' - condition: succeededOrFailed() + - task: PublishBuildArtifacts@1 + displayName: 'Publish site build artifact' + inputs: + PathtoPublish: '$(Build.SourcesDirectory)/docs/public' + ArtifactName: 'fluidframework-docs' + publishLocation: 'Container' + + # BEGIN Secure development tasks +- stage: guardian + displayName: Guardian + dependsOn: [] # run in parallel + pool: + vmImage: windows-latest + jobs: + - job: guardian_tasks + displayName: Guardian tasks + steps: + - checkout: self + submodules: false + clean: true - - task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@3 - displayName: 'Publish Guardian Artifacts - All Tools' - condition: succeededOrFailed() - inputs: - ArtifactType: M365 + - task: UseNode@1 + displayName: 'Use Node 14.x' + inputs: + version: 14.x - - task: AssetRetention@3 - displayName: Guardian Asset Retention - condition: and(succeeded(), eq(variables.shouldRetainGuardianAssets, true)) - inputs: - ArrowServiceConnection: 'Arrow_FluidFramework_internal' - AssetGroupName: 'fluidframework_$(System.TeamProject)_$(Build.DefinitionName)' - AssetNumber: '$(Build.BuildId)' - IsShipped: false # based on value of arrow.releasedtoproduction variable - DropsToRetain: 'CodeAnalysisLogs' + - task: UseDotNet@2 + displayName: 'Use .NET Core 3.x' + condition: succeededOrFailed() + inputs: + packageType: sdk + version: 3.x - - task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@2 - displayName: 'Guardian Break' - condition: succeededOrFailed() - inputs: - GdnBreakPolicyMinSev: Warning - GdnBreakAllTools: true - GdnBreakBaselineFiles: '$(Build.SourcesDirectory)/docs/.gdnbaselines' - GdnBreakGdnToolESLint: true - GdnBreakGdnToolESLintSeverity: Warning - GdnBreakPolicy: M365 - GdnBreakOutputBaselineFile: '$(Build.ArtifactStagingDirectory)\' - continueOnError: true + - task: securedevelopmentteam.vss-secure-development-tools.build-task-eslint.ESLint@1 + displayName: 'Run ESLint' + condition: succeededOrFailed() - - task: PublishPipelineArtifact@1 - displayName: 'Publish Baselines' - condition: eq('${{ parameters.publishGuardianBaselines }}', 'true') - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)\.gdnbaselines' - artifact: .gdn + - task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@3 + displayName: 'Publish Guardian Artifacts - All Tools' + condition: succeededOrFailed() + inputs: + ArtifactType: M365 - # END Secure development tasks + - task: AssetRetention@3 + displayName: Guardian Asset Retention + condition: and(succeeded(), eq(variables.shouldRetainGuardianAssets, true)) + inputs: + ArrowServiceConnection: 'Arrow_FluidFramework_internal' + AssetGroupName: 'fluidframework_$(System.TeamProject)_$(Build.DefinitionName)' + AssetNumber: '$(Build.BuildId)' + IsShipped: false # based on value of arrow.releasedtoproduction variable + DropsToRetain: 'CodeAnalysisLogs' - - task: Npm@1 - displayName: npm ci - inputs: - command: 'custom' - workingDir: '$(Build.SourcesDirectory)/docs' - customCommand: 'ci' + - task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@2 + displayName: 'Guardian Break' + condition: succeededOrFailed() + continueOnError: false + inputs: + GdnBreakPolicyMinSev: Warning + GdnBreakAllTools: true + GdnBreakBaselineFiles: '$(Build.SourcesDirectory)/docs/.gdnbaselines' + GdnBreakGdnToolESLint: true + GdnBreakGdnToolESLintSeverity: Warning + GdnBreakPolicy: M365 + GdnBreakOutputBaselineFile: '$(Build.ArtifactStagingDirectory)\' - - task: Npm@1 - displayName: npm run build - inputs: - command: 'custom' - workingDir: '$(Build.SourcesDirectory)/docs' - customCommand: 'run build' + - task: PublishPipelineArtifact@1 + displayName: 'Publish Baselines' + condition: eq('${{ parameters.publishGuardianBaselines }}', 'true') + inputs: + targetPath: '$(Build.ArtifactStagingDirectory)\.gdnbaselines' + artifact: .gdn +# END Secure development tasks - - task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0 - displayName: 'Generate SBOM' - inputs: - BuildDropPath: '$(Build.SourcesDirectory)/docs/public' - PackageName: 'fluidframework-docs' - PackageVersion: '$(Build.BuildId)' +- stage: deploy + displayName: 'Deploy website' + pool: Small + dependsOn: ['build', 'guardian'] + jobs: + - job: deploy_site + displayName: 'Deploy website' + steps: + - checkout: self + submodules: false + clean: true - - task: PublishBuildArtifacts@1 - displayName: 'Publish site build artifact' - inputs: - PathtoPublish: '$(Build.SourcesDirectory)/docs/public' - ArtifactName: 'fluidframework-docs' - publishLocation: 'Container' + - task: DownloadPipelineArtifact@2 + displayName: 'Copy fluidframework-docs to public folder' + inputs: + source: current + artifact: fluidframework-docs + path: '$(Build.SourcesDirectory)/docs/public' - - task: AzureStaticWebApp@0 - displayName: 'Deploy site' - condition: eq(variables.shouldDeploy, true) - inputs: - skip_app_build: true # site was built in previous step - cwd: $(Build.SourcesDirectory) - app_location: 'docs/public' - output_location: '' - azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN) + - task: AzureStaticWebApp@0 + displayName: 'Deploy website to ASWA' + condition: eq(variables.shouldDeploy, true) + inputs: + skip_app_build: true # site was built in previous stage + cwd: $(Build.SourcesDirectory) + app_location: 'docs/public' + output_location: '' + azure_static_web_apps_api_token: '${{ variables.deploymentToken }}' diff --git a/tools/pipelines/templates/upload-json-steps.yml b/tools/pipelines/templates/upload-json-steps.yml index f0638cfd6f28..57923b48dba2 100644 --- a/tools/pipelines/templates/upload-json-steps.yml +++ b/tools/pipelines/templates/upload-json-steps.yml @@ -67,6 +67,7 @@ steps: - task: AzureCLI@2 displayName: 'Upload JSON' + continueOnError: true inputs: azureSubscription: 'fluid-docs' scriptType: bash @@ -77,9 +78,10 @@ steps: - ${{ if eq(parameters.uploadAsLatest, true) }}: - task: AzureCLI@2 displayName: 'Upload JSON as latest.tar.gz' + continueOnError: true inputs: azureSubscription: 'fluid-docs' scriptType: bash scriptLocation: inlineScript inlineScript: | - az storage blob upload -f '$(Pipeline.Workspace)/$(Build.SourceVersion).tar.gz' -c 'api-extractor-json' -n latest.tar.gz --account-name ${{ parameters.STORAGE_ACCOUNT }} --account-key ${{ parameters.STORAGE_KEY }} --verbose + az storage blob upload -f '$(Pipeline.Workspace)/$(Build.SourceVersion).tar.gz' -c 'api-extractor-json' -n latest.tar.gz --account-name ${{ parameters.STORAGE_ACCOUNT }} --account-key ${{ parameters.STORAGE_KEY }} --overwrite --verbose