Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeckert authored Feb 23, 2019
2 parents 21083ea + 9ba4dc9 commit a2ee70f
Show file tree
Hide file tree
Showing 33 changed files with 905 additions and 73 deletions.
35 changes: 35 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,39 @@ jobs:
name: Lint
command: npm run lint

incompatibility-check:
docker:
# specify the version you desire here
- image: circleci/node:7.10

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/mongo:3.4.4

working_directory: ~/repo

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: npm install

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

# incompatibility-check
- run: npm run incompatibility-check


build:
docker:
# specify the version you desire here
Expand Down Expand Up @@ -119,9 +152,11 @@ workflows:
build:
jobs:
- lint-json
- incompatibility-check
- build:
requires:
- lint-json
- incompatibility-check
- generate-docs:
filters:
branches:
Expand Down
139 changes: 139 additions & 0 deletions bin/incompatibility-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#!/usr/bin/env node

/*
1.The script will check breaking changes as mentioned below and throw out errors to fail the build if needed
-when an existing schema file got removed (rename a file will be breaking change in this case).
-when an field got removed from the schema
-when a field's data type got changed
-when the value of $ref is changed
-when a $ref got removed from allOf
2.The script will only generate warning messages for cases below.
-when the meta:extends does not match allOf
*/

const fs = require('fs');
const glob = require("glob");
const shell = require('shelljs');
const diff = require('deep-diff');
const masterCopyLoc = "../tempmaster/";
const masterSchemaFolder = masterCopyLoc + "schemas";
const masterExtensionFolder = masterCopyLoc + "extensions";

shell.rm("-rf", masterCopyLoc); //start
if (shell.exec('git clone https://github.com/adobe/xdm.git ' + masterCopyLoc).code !== 0) {
shell.echo('Error: Git clone master branch failed');
shell.exit(1);
}

var jsonDataTypes = ["string", "number", "integer", "array", "object", "boolean"];
var schemaFiles = glob.sync(masterSchemaFolder + "/**/*.schema.json");
schemaFiles = schemaFiles.concat(glob.sync(masterExtensionFolder + "/**/*.schema.json"));

checkBreakingChanges(schemaFiles);
shell.rm("-rf", masterCopyLoc); //done

function checkBreakingChanges(files) {
files.forEach(function (file) {
var err;
console.log('Check breaking changes -->' + file);
var originalSchema = JSON.parse(fs.readFileSync(file).toString());
var workingFile = file.replace("tempmaster/", "");

try { //check if schema file got removed
var newSchema = JSON.parse(fs.readFileSync(workingFile).toString());
} catch (err) {
if (err.code = "ENOENT" && err.message.indexOf("ENOENT: no such file or directory") != -1)
createError("Breaking changes found!!! --> " + workingFile.replace("../", "") + " can not be removed");
else
createError(err) //raise other validation errors
}

var allOfCheck = isAllOfBroken(originalSchema["allOf"], newSchema["allOf"]); //check deleted allOfs
if (originalSchema["allOf"] && allOfCheck.isBroken) {
createError('Breaking changes found!!! {"$ref": "' + allOfCheck["$ref"] + '"} inside "allOf" can not be removed.');
}

if (newSchema["meta:extends"] && Array.isArray(newSchema["meta:extends"]) && isMetaExtendsBroken(newSchema["meta:extends"], newSchema["allOf"])) { //check meta:extends against allOf
console.log('Warning: Incompatible "meta:extends" vs "allOf" found!!! The schemas inside "meta:extends" did not match those in "allOf".')
}

var differences = diff(originalSchema, newSchema);
var brokenProperty = {};
if (differences && isPropertyRemoved(differences, brokenProperty)) { //check removed properties
createError('Breaking changes found!!! Property "' + brokenProperty.name + '" can not be removed.');
}

if (differences && isFieldTypeChanged(differences, brokenProperty)) { //check changed data types
createError('Breaking changes found!!! Data type of property "' + brokenProperty.name + '" can not be changed.');
}

});
}

function isAllOfBroken(origAllOf, newAllOf) {
var isBroken;
for (var i in origAllOf) {
isBroken = true;
for (var j in newAllOf) {
if (JSON.stringify(origAllOf[i]) == JSON.stringify(newAllOf[j])) isBroken = false;
}
if (isBroken)
return {
"isBroken": true,
"$ref": origAllOf[i]["$ref"]
}
}

return {
"isBroken": false
}
}

function isMetaExtendsBroken(metaExtends, newAllOf) {
var allOfSchemas = [];
for (var i in newAllOf) {
if (newAllOf[i]["$ref"] && newAllOf[i]["$ref"].indexOf("#/definitions/") != 0 && newAllOf[i]["$ref"].indexOf("http") == 0)
allOfSchemas.push(newAllOf[i]["$ref"])
}

if (diff(metaExtends.sort(), allOfSchemas.sort())) {
//console.log(diff(metaExtends.sort(), allOfSchemas.sort()))
return true
} else
return false

}

function isPropertyRemoved(differences, brokenProperty) {
for (var i in differences) {
if (differences[i].kind == "D") {
if (differences[i].path.indexOf("properties") != -1) {
brokenProperty.name = differences[i].path.join("/").replace("../", "");
return true;
}
}
}
return false;
}

function isFieldTypeChanged(differences, brokenProperty) {
for (var i in differences) {
if (differences[i].kind == "E") {
if ((differences[i].path[differences[i].path.length - 1] == '$ref' && differences[i].path.indexOf("allOf") == -1) ||
(differences[i].path[differences[i].path.length - 1] == 'type' && jsonDataTypes.indexOf(differences[i].lhs.toLowerCase() != -1))) {
brokenProperty.name = differences[i].path.join("/").replace("../", "");
return true;
}

}
}
return false;

}


function createError(err) {
shell.rm("-rf", masterCopyLoc);
throw (err);
}
103 changes: 103 additions & 0 deletions extensions/adobe/experience/aam-experienceevent.example.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"@id": "https://data.adobe.io/experienceid-123456",
"xdm:dataSource": {
"@id": "https://data.adobe.io/datasources/datasource-123",
"xdm:code": "DataSourceIntegrationCode-123"
},
"xdm:timestamp": "2017-09-26T15:52:25+00:00",
"xdm:identityMap": {
"https://data.adobe.io/entities/namespace/4": [
{
"xdm:id": "92312748749128"
}
],
"https://data.adobe.io/entities/namespace/10": [
{
"xdm:id": "2394509340-30453470347"
}
],
"https://data.adobe.io/entities/namespace/9": [
{
"xdm:id": "1233ce17-20e0-4a2c-8198-2a77fd60cf4d"
}
]
},
"xdm:environment": {
"xdm:type": "browser",
"xdm:browserDetails": {
"xdm:name": "Chrome",
"xdm:version": "63.0.3239",
"xdm:acceptLanguage": "en",
"xdm:cookiesEnabled": true,
"xdm:javaScriptEnabled": true,
"xdm:javaScriptVersion": "1.8.5",
"xdm:javaEnabled": true,
"xdm:javaVersion": "Java SE 8",
"xdm:viewportHeight": 900,
"xdm:viewportWidth": 1680
},
"xdm:operatingSystem": "MAC OS",
"xdm:operatingSystemVersion": "10.13",
"xdm:connectionType": "cable"
},
"xdm:placeContext": {
"xdm:localTime": "2017-09-26T15:52:25+13:00",
"xdm:geo": {
"@id": "https://data.adobe.io/entities/geo/tokyo",
"xdm:countryCode": "JP",
"xdm:stateProvince": "JP-13",
"xdm:city": "Tōkyō",
"xdm:postalCode": "141-0032",
"schema:latitude": 35.6185,
"schema:longitude": 139.73237
}
},
"xdm:profileStitch": [
{
"xdm:profileStitchID": {
"@id": "https://data.adobe.io/entities/profileStitchIdentity/1",
"xdm:namespace": {
"xdm:code": "AAM"
}
},
"xdm:version": "1.0",
"xdm:identityMap": {
"ECID": [
{
"xdm:id": "https://data.adobe.io/entities/identity/92312748749128"
},
{
"xdm:id": "https://data.adobe.io/entities/identity/62312748749321"
},
{
"xdm:id": "https://data.adobe.io/entities/identity/49312748749132"
}
]
}
}
],
"xdm:segmentMemberships": [
{
"xdm:segmentID": {
"@id": "https://data.adobe.io/entities/identity/92312748749128",
"xdm:namespace": {
"xdm:code": "AAM"
}
},
"xdm:profileStitchID": {
"@id": "https://data.adobe.io/entities/profileStitchIdentity/1",
"xdm:namespace": {
"xdm:code": "AAM"
},
"xdm:lastQualificationTime": "2017-09-26T15:52:25+00:00",
"xdm:version": "1.0",
"xdm:validUntil": "2017-12-26T15:52:25+00:00",
"xdm:status": "realized"
}
}
],
"xdm:signals": {
"pageTagCloud": ["analytics", "bigdata"],
"pagelinkshovered": ["http://abcxyzabcxyz.com", "http://abcxyzabcxyz1.com"]
}
}
45 changes: 45 additions & 0 deletions extensions/adobe/experience/aam-experienceevent.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"meta:license": [
"Copyright 2018 Adobe Systems Incorporated. All rights reserved.",
"This work is licensed under a Creative Commons Attribution 4.0 International (CC BY 4.0) license",
"you may not use this file except in compliance with the License. You may obtain a copy",
"of the License at https://creativecommons.org/licenses/by/4.0/"
],
"$id": "https://ns.adobe.com/experience/aam-experienceevent",
"$schema": "http://json-schema.org/draft-06/schema#",
"title": "Adobe Audience Manager Template Mixin",
"type": "object",
"description": "Adobe Audience Manager Mixin for use with Schemas for Solution data ingestion. Includes the core/standard ExperienceEvent as well as the other required Core mixins.",
"meta:extensible": true,
"meta:abstract": true,
"meta:intendedToExtend": ["https://ns.adobe.com/xdm/context/experienceevent"],
"meta:extends": [
"https://ns.adobe.com/xdm/context/experienceevent-segmentmembership",
"https://ns.adobe.com/xdm/context/experienceevent-environment-details",
"https://ns.adobe.com/xdm/context/experienceevent-profile-stitch",
"https://ns.adobe.com/experience/audiencemanager/experienceevent-all"
],
"definitions": {
"aam-experienceevent": {
"properties": {}
}
},
"allOf": [
{
"$ref": "https://ns.adobe.com/xdm/context/experienceevent-segmentmembership"
},
{
"$ref": "https://ns.adobe.com/xdm/context/experienceevent-environment-details"
},
{
"$ref": "https://ns.adobe.com/xdm/context/experienceevent-profile-stitch"
},
{
"$ref": "https://ns.adobe.com/experience/audiencemanager/experienceevent-all"
},
{
"$ref": "#/definitions/aam-experienceevent"
}
],
"meta:status": "experimental"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"https://ns.adobe.com/experience/target/experienceevent-shared",
"https://ns.adobe.com/experience/profile/experienceevent-shared",
"https://ns.adobe.com/experience/implementations-ext",
"https://ns.adobe.com/xdm/context/experienceevent-enduserids-deprecated"
"https://ns.adobe.com/xdm/context/experienceevent-enduserids"
],
"definitions": {
"adcloud-experienceevent": {
Expand Down Expand Up @@ -94,7 +94,7 @@
"$ref": "https://ns.adobe.com/experience/implementations-ext"
},
{
"$ref": "https://ns.adobe.com/xdm/context/experienceevent-enduserids-deprecated"
"$ref": "https://ns.adobe.com/xdm/context/experienceevent-enduserids"
},
{
"$ref": "#/definitions/adcloud-experienceevent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
"title": "Ad Asset Details",
"$ref": "https://ns.adobe.com/experience/adcloud/advertisement",
"description": "Digital advertisement details"
},
"https://ns.adobe.com/experience/adcloud/stitchId": {
"title": "Stitch ID Chosen",
"type": "string",
"description": "ID from the Ad Servers through AdCloud STATS to track click-through conversion on browsers that block third party cookies"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"https://ns.adobe.com/experience/target/experienceevent-shared",
"https://ns.adobe.com/experience/profile/experienceevent-shared",
"https://ns.adobe.com/experience/implementations-ext",
"https://ns.adobe.com/xdm/context/experienceevent-enduserids-deprecated"
"https://ns.adobe.com/xdm/context/experienceevent-enduserids"
],
"definitions": {
"analytics-experienceevent": {
Expand Down Expand Up @@ -94,7 +94,7 @@
"$ref": "https://ns.adobe.com/experience/implementations-ext"
},
{
"$ref": "https://ns.adobe.com/xdm/context/experienceevent-enduserids-deprecated"
"$ref": "https://ns.adobe.com/xdm/context/experienceevent-enduserids"
},
{
"$ref": "#/definitions/analytics-experienceevent"
Expand Down
Loading

0 comments on commit a2ee70f

Please sign in to comment.