Skip to content

Commit

Permalink
SzEngine examples
Browse files Browse the repository at this point in the history
  • Loading branch information
arawinters committed Jan 23, 2025
1 parent ec12eb9 commit fc76333
Show file tree
Hide file tree
Showing 28 changed files with 327 additions and 32 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ MAKEFILE_PATH := $(abspath $(firstword $(MAKEFILE_LIST)))
MAKEFILE_DIRECTORY := $(shell dirname $(MAKEFILE_PATH))
DIST_DIRECTORY := $(MAKEFILE_DIRECTORY)/dist
NS_DIRECTORY := $(DIST_DIRECTORY)/@senzing
TARGET_DIRECTORY := $(DIST_DIRECTORY)/@senzing/sz-sdk-typescript-grpc
#TARGET_DIRECTORY := $(DIST_DIRECTORY)/@senzing/sz-sdk-typescript-grpc
TARGET_DIRECTORY := $(NS_DIRECTORY)/sz-sdk-typescript-grpc
BUILD_VERSION := $(shell git describe --always --tags --abbrev=0 --dirty | sed 's/v//')
BUILD_TAG := $(shell git describe --always --tags --abbrev=0 | sed 's/v//')
BUILD_ITERATION := $(shell git log $(BUILD_TAG)..HEAD --oneline | wc -l | sed 's/^ *//')
Expand Down
25 changes: 2 additions & 23 deletions examples/szengine/addRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ const szParamFactory = new SzAbstractFactory(`0.0.0.0:8261`);
const szEngine = szParamFactory.createEngine();

const DATA_SOURCE_CODE = "TEST";
const FLAGS = SzEngineFlags.SZ_WITH_INFO; // should be "4611686018427387904" not "1073741824"
//const FLAGS = 4611686018427387904;
const FLAGS = SzEngineFlags.SZ_WITH_INFO;
const RECORD_DEFINITION = {
"RECORD_TYPE": "PERSON",
"PRIMARY_NAME_LAST": "Smith",
Expand All @@ -20,28 +19,8 @@ const RECORD_DEFINITION = {
"STATUS": "Active",
"AMOUNT": "100"
};
/*const RECORD_DEFINITION = '{'+
'"RECORD_TYPE":"PERSON",'+
'"PRIMARY_NAME_LAST":"Smith",'+
'"PRIMARY_NAME_FIRST":"Robert",'+
'"DATE_OF_BIRTH":"12/11/1978",'+
'"ADDR_TYPE":"MAILING",'+
'"ADDR_LINE1":"123 Main Street, Las Vegas NV 89132",'+
'"PHONE_TYPE":"HOME",'+
'"PHONE_NUMBER":"702-919-1300",'+
'"EMAIL_ADDRESS":"bsmith@work.com",'+
'"DATE":"1/2/18",'+
'"STATUS":"Active",'+
'"AMOUNT":"100"'+
'}';*/
const RECORD_ID = "1";

await szEngine.addRecord(DATA_SOURCE_CODE, RECORD_ID, RECORD_DEFINITION, FLAGS).then((resp) => {
console.log('Hi!', resp);
});

/*szEngine.addRecord(DATA_SOURCE_CODE, RECORD_ID, RECORD_DEFINITION).then((resp) => {
console.log(`RESULT #${RECORD_ID}:\n${resp}`);
}).catch((err) => {
console.error(err);
})*/
});
10 changes: 10 additions & 0 deletions examples/szengine/countRedoRecords.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();

szEngine.countRedoRecords().then((result) => {
console.log(`Redo Records: ${result}`);
}).catch((err) => {
console.error(err);
})
13 changes: 13 additions & 0 deletions examples/szengine/deleteRecord.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();
const DATA_SOURCE_CODE = "TEST";
const FLAGS = SzEngineFlags.SZ_WITH_INFO
const RECORD_ID = "1";

szEngine.deleteRecord(DATA_SOURCE_CODE, RECORD_ID, FLAGS).then((result) => {
console.log(`Redo Records: ${result}`);
}).catch((err) => {
console.error(err);
})
12 changes: 12 additions & 0 deletions examples/szengine/findInterestingEntitiesByEntityId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();
const FLAGS = SzEngineFlags.SZ_WITH_INFO
const ENTITY_ID = 1;

szEngine.findInterestingEntitiesByEntityId(ENTITY_ID, FLAGS).then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
13 changes: 13 additions & 0 deletions examples/szengine/findInterestingEntitiesByRecordId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();
const DATA_SOURCE_CODE = "TEST";
const FLAGS = SzEngineFlags.SZ_WITH_INFO
const RECORD_ID = "1";

szEngine.findInterestingEntitiesByRecordId(DATA_SOURCE_CODE, RECORD_ID, FLAGS).then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
16 changes: 16 additions & 0 deletions examples/szengine/findNetworkByEntityId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();

const FLAGS = SzEngineFlags.SZ_FIND_NETWORK_DEFAULT_FLAGS;
const BUILD_OUT_DEGREES = 1;
const MAX_DEGREES = 2;
const MAX_ENTITIES = 10;
const ENTITY_IDS = [1, 4];

szEngine.findNetworkByEntityId(ENTITY_IDS, MAX_DEGREES, BUILD_OUT_DEGREES, MAX_ENTITIES, FLAGS).then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
19 changes: 19 additions & 0 deletions examples/szengine/findNetworkByRecordId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();

const FLAGS = SzEngineFlags.SZ_FIND_NETWORK_DEFAULT_FLAGS;
const BUILD_OUT_DEGREES = 1;
const MAX_DEGREES = 2;
const MAX_ENTITIES = 10;
const RECORDS:[string, string | number][] = [
["CUSTOMERS", "1001"],
["CUSTOMERS", "1009"]
];

szEngine.findNetworkByRecordId(RECORDS, MAX_DEGREES, BUILD_OUT_DEGREES, MAX_ENTITIES, FLAGS).then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
12 changes: 12 additions & 0 deletions examples/szengine/findPathByEntityId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();

const FLAGS = SzEngineFlags.SZ_FIND_NETWORK_DEFAULT_FLAGS;

szEngine.findPathByEntityId(1, 2, 2, [], [], FLAGS).then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
21 changes: 21 additions & 0 deletions examples/szengine/findPathByRecordId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();

const FLAGS = SzEngineFlags.SZ_FIND_NETWORK_DEFAULT_FLAGS;

szEngine.findPathByRecordId(
"CUSTOMERS",
"1001",
"CUSTOMERS",
"1009",
2,
[],
[],
FLAGS).
then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
10 changes: 10 additions & 0 deletions examples/szengine/getActiveConfigId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();

szEngine.getActiveConfigId().then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
10 changes: 10 additions & 0 deletions examples/szengine/getEntityById.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();

szEngine.getEntityByEntityId(1, SzEngineFlags.SZ_ENTITY_DEFAULT_FLAGS).then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
10 changes: 10 additions & 0 deletions examples/szengine/getEntityByRecordId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();

szEngine.getEntityByRecordId("CUSTOMERS", "1001", SzEngineFlags.SZ_ENTITY_DEFAULT_FLAGS).then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
10 changes: 10 additions & 0 deletions examples/szengine/getRecord.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();

szEngine.getRecord("CUSTOMERS", "1001", SzEngineFlags.SZ_RECORD_DEFAULT_FLAGS).then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
10 changes: 10 additions & 0 deletions examples/szengine/getRedoRecord.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();

szEngine.getRedoRecord().then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
10 changes: 10 additions & 0 deletions examples/szengine/getStats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();

szEngine.getStats().then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
14 changes: 14 additions & 0 deletions examples/szengine/getVirtualEntityByRecordId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();
const RECORD_LIST:[string, string | number][] = [
["CUSTOMERS", "1001"],
["CUSTOMERS", "1002"],
]

szEngine.getVirtualEntityByRecordId(RECORD_LIST, SzEngineFlags.SZ_VIRTUAL_ENTITY_DEFAULT_FLAGS).then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
10 changes: 10 additions & 0 deletions examples/szengine/howEntityByEntityId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();

szEngine.howEntityByEntityId(1, SzEngineFlags.SZ_HOW_ENTITY_DEFAULT_FLAGS).then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
26 changes: 26 additions & 0 deletions examples/szengine/preprocessrecord.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { SzAbstractFactory, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const szParamFactory = new SzAbstractFactory(`0.0.0.0:8261`);
const szEngine = szParamFactory.createEngine();

const DATA_SOURCE_CODE = "TEST";
const FLAGS = SzEngineFlags.SZ_RECORD_DEFAULT_FLAGS;
const RECORD_DEFINITION = {
"RECORD_TYPE": "PERSON",
"PRIMARY_NAME_LAST": "Smith",
"PRIMARY_NAME_FIRST": "Robert",
"DATE_OF_BIRTH": "12/11/1978",
"ADDR_TYPE": "MAILING",
"ADDR_LINE1": "123 Main Street, Las Vegas NV 89132",
"PHONE_TYPE": "HOME",
"PHONE_NUMBER": "702-919-1300",
"EMAIL_ADDRESS": "bsmith@work.com",
"DATE": "1/2/18",
"STATUS": "Active",
"AMOUNT": "100"
};
const RECORD_ID = "1";

await szEngine.preprocessRecord(JSON.stringify(RECORD_DEFINITION), FLAGS).then((resp) => {
console.log(`RESULT #${RECORD_ID}:\n${resp}`);
});
10 changes: 10 additions & 0 deletions examples/szengine/reevaluateEntity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SzAbstractFactory, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const szParamFactory = new SzAbstractFactory(`0.0.0.0:8261`);
const szEngine = szParamFactory.createEngine();

szEngine.reevaluateEntity(1, SzEngineFlags.SZ_WITH_INFO).then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
});
10 changes: 10 additions & 0 deletions examples/szengine/reevaluateRecord.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SzAbstractFactory, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const szParamFactory = new SzAbstractFactory(`0.0.0.0:8261`);
const szEngine = szParamFactory.createEngine();

szEngine.reevaluateRecord("CUSTOMERS", "1001", SzEngineFlags.SZ_WITH_INFO).then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
});
18 changes: 18 additions & 0 deletions examples/szengine/searchByAttributes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();
const ATTRIBUTES = {
"NAME_FULL": "BOB SMITH",
"EMAIL_ADDRESS": "bsmith@work.com"
};

szEngine.searchByAttributes(
ATTRIBUTES,
SzEngineFlags.SZ_SEARCH_BY_ATTRIBUTES_DEFAULT_FLAGS,
"").
then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
4 changes: 4 additions & 0 deletions examples/szengine/szEngineConstructor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();
15 changes: 15 additions & 0 deletions examples/szengine/whyEntities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzAbstractFactoryOptions, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();

szEngine.whyEntities(
1,
4,
SzEngineFlags.SZ_SEARCH_BY_ATTRIBUTES_DEFAULT_FLAGS,
).
then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
15 changes: 15 additions & 0 deletions examples/szengine/whyRecordInEntities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { SzAbstractFactory as szAbstractFactoryCreator, SzEngineFlags } from '../../dist/@senzing/sz-sdk-typescript-grpc';

const SzAbstractFactory = new szAbstractFactoryCreator(`0.0.0.0:8261`);
const szEngine = SzAbstractFactory.createEngine();

szEngine.whyRecordInEntity(
"CUSTOMERS",
"1001",
SzEngineFlags.SZ_WHY_RECORDS_DEFAULT_FLAGS,
).
then((result) => {
console.log(`RESULT: ${result}`);
}).catch((err) => {
console.error(err);
})
Loading

0 comments on commit fc76333

Please sign in to comment.