@contrail/flexplm 1.5.0-alpha.98b8b06 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/pull_request_template.md +31 -0
- package/.github/workflows/flexplm-lib.yml +27 -0
- package/.github/workflows/publish-to-npm.yml +121 -0
- package/CHANGELOG.md +45 -0
- package/lib/entity-processor/base-entity-processor.d.ts +0 -65
- package/lib/entity-processor/base-entity-processor.js +0 -71
- package/lib/entity-processor/base-entity-processor.spec.js +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/publish/base-process-publish-assortment.d.ts +0 -25
- package/lib/publish/base-process-publish-assortment.js +6 -60
- package/lib/publish/base-process-publish-assortment.spec.js +4 -22
- package/lib/publish/mockData.js +0 -5
- package/lib/transform/identifier-conversion-spec-mockData.js +6 -34
- package/lib/transform/identifier-conversion.d.ts +0 -36
- package/lib/transform/identifier-conversion.js +0 -36
- package/lib/transform/identifier-conversion.spec.js +0 -4
- package/lib/util/config-defaults.js +0 -3
- package/lib/util/config-defaults.spec.js +0 -9
- package/lib/util/data-converter-spec-mockData.js +3 -17
- package/lib/util/data-converter.d.ts +0 -97
- package/lib/util/data-converter.js +1 -127
- package/lib/util/data-converter.spec.js +0 -2
- package/lib/util/error-response-object.d.ts +0 -5
- package/lib/util/error-response-object.js +0 -7
- package/lib/util/event-short-message-status.js +0 -1
- package/lib/util/federation.js +0 -8
- package/lib/util/flexplm-connect.d.ts +0 -7
- package/lib/util/flexplm-connect.js +0 -14
- package/lib/util/logger-config.js +0 -1
- package/lib/util/map-util-spec-mockData.js +3 -17
- package/lib/util/map-utils.d.ts +0 -27
- package/lib/util/map-utils.js +0 -27
- package/lib/util/thumbnail-util.d.ts +0 -21
- package/lib/util/thumbnail-util.js +1 -28
- package/lib/util/thumbnail-util.spec.js +0 -6
- package/lib/util/type-conversion-utils-spec-mockData.js +3 -3
- package/lib/util/type-conversion-utils.d.ts +1 -152
- package/lib/util/type-conversion-utils.js +1 -155
- package/lib/util/type-defaults.d.ts +0 -66
- package/lib/util/type-defaults.js +0 -66
- package/lib/util/type-defaults.spec.js +5 -5
- package/lib/util/type-utils.d.ts +0 -21
- package/lib/util/type-utils.js +0 -23
- package/lib/util/type-utils.spec.js +0 -2
- package/package.json +6 -21
- package/publish.bat +5 -0
- package/publish.sh +5 -0
- package/src/entity-processor/base-entity-processor.spec.ts +689 -0
- package/src/entity-processor/base-entity-processor.ts +583 -0
- package/src/flexplm-request.ts +28 -0
- package/src/flexplm-utils.spec.ts +27 -0
- package/src/flexplm-utils.ts +29 -0
- package/src/index.ts +22 -0
- package/src/interfaces/interfaces.ts +122 -0
- package/src/interfaces/item-family-changes.ts +67 -0
- package/src/interfaces/publish-change-data.ts +43 -0
- package/src/publish/base-process-publish-assortment-callback.ts +50 -0
- package/src/publish/base-process-publish-assortment.spec.ts +1992 -0
- package/src/publish/base-process-publish-assortment.ts +1134 -0
- package/src/publish/mockData.ts +4561 -0
- package/src/transform/identifier-conversion-spec-mockData.ts +496 -0
- package/src/transform/identifier-conversion.spec.ts +386 -0
- package/src/transform/identifier-conversion.ts +282 -0
- package/src/util/config-defaults.spec.ts +445 -0
- package/src/util/config-defaults.ts +106 -0
- package/src/util/data-converter-spec-mockData.ts +231 -0
- package/src/util/data-converter.spec.ts +1622 -0
- package/src/util/data-converter.ts +819 -0
- package/src/util/error-response-object.spec.ts +116 -0
- package/src/util/error-response-object.ts +50 -0
- package/src/util/event-short-message-status.ts +22 -0
- package/src/util/federation.ts +172 -0
- package/src/util/flexplm-connect.spec.ts +132 -0
- package/src/util/flexplm-connect.ts +208 -0
- package/src/util/logger-config.ts +20 -0
- package/src/util/map-util-spec-mockData.ts +231 -0
- package/src/util/map-utils.spec.ts +103 -0
- package/src/util/map-utils.ts +41 -0
- package/src/util/mockData.ts +101 -0
- package/src/util/thumbnail-util.spec.ts +508 -0
- package/src/util/thumbnail-util.ts +272 -0
- package/src/util/type-conversion-utils-spec-mockData.ts +272 -0
- package/src/util/type-conversion-utils.spec.ts +1031 -0
- package/src/util/type-conversion-utils.ts +490 -0
- package/src/util/type-defaults.spec.ts +797 -0
- package/src/util/type-defaults.ts +320 -0
- package/src/util/type-utils.spec.ts +227 -0
- package/src/util/type-utils.ts +144 -0
- package/tsconfig.json +24 -0
- package/tslint.json +57 -0
- package/lib/cli/commands/compile.d.ts +0 -4
- package/lib/cli/commands/compile.js +0 -73
- package/lib/cli/commands/compile.spec.d.ts +0 -1
- package/lib/cli/commands/compile.spec.js +0 -80
- package/lib/cli/commands/create.d.ts +0 -5
- package/lib/cli/commands/create.js +0 -77
- package/lib/cli/commands/create.spec.d.ts +0 -1
- package/lib/cli/commands/create.spec.js +0 -78
- package/lib/cli/commands/upload.d.ts +0 -17
- package/lib/cli/commands/upload.js +0 -228
- package/lib/cli/commands/upload.spec.d.ts +0 -1
- package/lib/cli/commands/upload.spec.js +0 -88
- package/lib/cli/index.d.ts +0 -5
- package/lib/cli/index.js +0 -70
- package/lib/cli/index.spec.d.ts +0 -1
- package/lib/cli/index.spec.js +0 -85
- package/lib/cli/template/mapping-template.ts.template +0 -62
- package/lib/interfaces/mapping-file.d.ts +0 -460
- package/lib/interfaces/mapping-file.js +0 -2
- package/scripts/copy-template.js +0 -10
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
## What
|
|
2
|
+
- [ ] Bugfix
|
|
3
|
+
- [ ] Feature
|
|
4
|
+
- [ ] Enhancement
|
|
5
|
+
|
|
6
|
+
Description:
|
|
7
|
+
<!--
|
|
8
|
+
Describe the functional changes of the PR.
|
|
9
|
+
|
|
10
|
+
If the mechanism of your change are complex, describe them in detail as you
|
|
11
|
+
would if you were explaining them to a team mate.
|
|
12
|
+
|
|
13
|
+
If the PR is simple, there is no need to repeat yourself. A small description
|
|
14
|
+
is sufficient.
|
|
15
|
+
-->
|
|
16
|
+
|
|
17
|
+
## Why
|
|
18
|
+
<!--
|
|
19
|
+
why is this change needed? Same rules as with #What
|
|
20
|
+
-->
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Testing added
|
|
24
|
+
<!--
|
|
25
|
+
Describe the testing you added to this PR
|
|
26
|
+
-->
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Link to Jira ticket(s)
|
|
30
|
+
https://vibe-team.atlassian.net/browse/VIBE-TICKET_NUMBER_HERE
|
|
31
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: flexplm-lib-tests
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
workflow_dispatch: # allow running in github actions manually
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
runs-on: ubuntu-24.04
|
|
8
|
+
strategy:
|
|
9
|
+
matrix:
|
|
10
|
+
node-version: [22.14.0, 24]
|
|
11
|
+
steps:
|
|
12
|
+
- name: Node.js
|
|
13
|
+
uses: actions/setup-node@v3
|
|
14
|
+
with:
|
|
15
|
+
node-version: ${{ matrix.node-version }}
|
|
16
|
+
|
|
17
|
+
- uses: actions/checkout@v3
|
|
18
|
+
|
|
19
|
+
- name: NPM Install
|
|
20
|
+
env:
|
|
21
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
22
|
+
run: npm ci
|
|
23
|
+
|
|
24
|
+
- name: Unit Tests -
|
|
25
|
+
env:
|
|
26
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
27
|
+
run: npm test
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
name: Publish to NPM
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
paths-ignore:
|
|
7
|
+
- '.github/**'
|
|
8
|
+
pull_request:
|
|
9
|
+
branches: [master]
|
|
10
|
+
paths-ignore:
|
|
11
|
+
- '.github/**'
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
check-version:
|
|
15
|
+
name: Verify version is available on npm
|
|
16
|
+
if: github.event_name == 'pull_request'
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Check version not already published
|
|
22
|
+
run: |
|
|
23
|
+
PACKAGE_NAME=$(node -p "require('./package.json').name")
|
|
24
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
25
|
+
echo "Checking if ${PACKAGE_NAME}@${VERSION} exists on npm..."
|
|
26
|
+
if npm view "${PACKAGE_NAME}@${VERSION}" version 2>/dev/null; then
|
|
27
|
+
echo "::error::Version ${VERSION} is already published on npm. Bump the version in package.json before merging."
|
|
28
|
+
exit 1
|
|
29
|
+
else
|
|
30
|
+
echo "Version ${VERSION} is available."
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
check-dependencies:
|
|
34
|
+
name: Verify no private dependencies
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v4
|
|
38
|
+
|
|
39
|
+
- name: Verify no private dependencies
|
|
40
|
+
run: |
|
|
41
|
+
node -e "
|
|
42
|
+
const deps = require('./package.json').dependencies || {};
|
|
43
|
+
const { execSync } = require('child_process');
|
|
44
|
+
let failed = false;
|
|
45
|
+
for (const pkg of Object.keys(deps)) {
|
|
46
|
+
try {
|
|
47
|
+
execSync('npm view ' + pkg, { stdio: 'pipe' });
|
|
48
|
+
} catch {
|
|
49
|
+
console.error('::error::Dependency ' + pkg + ' is not publicly accessible on npm');
|
|
50
|
+
failed = true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (failed) process.exit(1);
|
|
54
|
+
console.log('All ' + Object.keys(deps).length + ' dependencies are public.');
|
|
55
|
+
"
|
|
56
|
+
|
|
57
|
+
publish-alpha:
|
|
58
|
+
name: Publish alpha
|
|
59
|
+
needs: check-dependencies
|
|
60
|
+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
|
|
61
|
+
runs-on: ubuntu-latest
|
|
62
|
+
permissions:
|
|
63
|
+
id-token: write
|
|
64
|
+
contents: read
|
|
65
|
+
outputs:
|
|
66
|
+
version: ${{ steps.publish.outputs.version }}
|
|
67
|
+
steps:
|
|
68
|
+
- uses: actions/checkout@v4
|
|
69
|
+
|
|
70
|
+
- uses: actions/setup-node@v4
|
|
71
|
+
with:
|
|
72
|
+
node-version: '24'
|
|
73
|
+
registry-url: 'https://registry.npmjs.org'
|
|
74
|
+
|
|
75
|
+
- name: Install and build
|
|
76
|
+
run: npm ci && npm run build
|
|
77
|
+
|
|
78
|
+
- name: Publish alpha
|
|
79
|
+
id: publish
|
|
80
|
+
run: |
|
|
81
|
+
SHORT_SHA=$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-7)
|
|
82
|
+
VERSION=$(node -p "require('./package.json').version")-alpha.${SHORT_SHA}
|
|
83
|
+
npm version $VERSION --no-git-tag-version
|
|
84
|
+
OUTPUT=$(npm publish --tag alpha 2>&1) && {
|
|
85
|
+
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
86
|
+
} || {
|
|
87
|
+
if echo "$OUTPUT" | grep -q "You cannot publish over the previously published versions"; then
|
|
88
|
+
echo "::warning::Alpha ${VERSION} already published, skipping."
|
|
89
|
+
else
|
|
90
|
+
echo "::error::Failed to publish alpha ${VERSION}"
|
|
91
|
+
echo "$OUTPUT"
|
|
92
|
+
exit 1
|
|
93
|
+
fi
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
publish-release:
|
|
97
|
+
name: Publish release
|
|
98
|
+
needs: check-dependencies
|
|
99
|
+
if: github.event_name == 'push'
|
|
100
|
+
runs-on: ubuntu-latest
|
|
101
|
+
permissions:
|
|
102
|
+
id-token: write
|
|
103
|
+
contents: read
|
|
104
|
+
outputs:
|
|
105
|
+
version: ${{ steps.publish.outputs.version }}
|
|
106
|
+
steps:
|
|
107
|
+
- uses: actions/checkout@v4
|
|
108
|
+
|
|
109
|
+
- uses: actions/setup-node@v4
|
|
110
|
+
with:
|
|
111
|
+
node-version: '24'
|
|
112
|
+
registry-url: 'https://registry.npmjs.org'
|
|
113
|
+
|
|
114
|
+
- name: Install and build
|
|
115
|
+
run: npm ci && npm run build
|
|
116
|
+
|
|
117
|
+
- name: Publish release
|
|
118
|
+
id: publish
|
|
119
|
+
run: |
|
|
120
|
+
npm publish
|
|
121
|
+
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@contrail/flexplm` are documented here.
|
|
4
|
+
|
|
5
|
+
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
6
|
+
Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [1.5.0] - 2026-05-12
|
|
11
|
+
### Added
|
|
12
|
+
- Added support for Inbound `LCSMaterial` to sync to the entity class `item` with type path `item:material` and `itemNumber` as identifier. This is controlled by an `LCSMaterial.processAsItem` (default `false`) config default.
|
|
13
|
+
- Added optional identity-service lookup in `DataConverter.setObjectReferenceValue` for resolving inbound `object_reference` values. Enabled per referenced entity type via `config.search.<entityType>.useIdentityServiceForInboundData`. When enabled the reference is resolved via the identity service using a uniqueness pool key; otherwise behavior falls through to the existing `getAllObjectReferences` query path.
|
|
14
|
+
|
|
15
|
+
## [1.4.0] - 2026-05-06
|
|
16
|
+
### Added
|
|
17
|
+
- Added `getEntityUsingIdentityService` method to `BaseEntityProcessor` for looking up entities via the identity service using a pool key and property criteria. Returns the resolved entity from the identity's `entityReference`, `undefined` if not found, or throws if multiple matches exist.
|
|
18
|
+
|
|
19
|
+
## [1.3.2] - 2026-05-01
|
|
20
|
+
### Added
|
|
21
|
+
- Added syncing Size Range properties; they sync as the raw VibeIQ data. For Example: { "sizes": { "30": ["30","32"], "32": ["30","32"]}, "dimension1": {"slug": "width","label": "Width"}, "dimension2": {"slug": "length", "label": "Length"}}
|
|
22
|
+
|
|
23
|
+
## [1.3.0] - 2026-04-15
|
|
24
|
+
### Added
|
|
25
|
+
- Added inbound thumbnail/primary content syncing from FlexPLM to VibeIQ via `ThumbnailUtil.syncThumbnailToVibeIQ`.
|
|
26
|
+
- Added `syncInboundImages` and `syncOutboundImages` methods to `TypeConversionUtils` for controlling image sync per map file configuration.
|
|
27
|
+
- Added `PRIMARY_CONTENT_UPDATED` status to `EventShortMessageStatus` for when only primary content changes are detected.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
- `BaseEntityProcessor` update flow now distinguishes between primary-content-only changes and no changes, returning the updated entity when only the thumbnail was synced.
|
|
31
|
+
- Improved `FlexPLMConnect.getRequest` function and added unit tests.
|
|
32
|
+
|
|
33
|
+
## [1.2.1] - 2026-04-08
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
- Added EventShortMessageStatus status values for adding items to projects functionality.
|
|
37
|
+
- Added `TypeConversionUtils.isOutboundCreatableFromEntity` method to determine if VibeIQ entities are creatable in FlexPLM (defaults to true).
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
- Added optional `context` parameter to `TypeConversionUtils.isInboundCreatableFromObject` method to allow passing context data to map file `isInboundCreatable` functions.
|
|
41
|
+
|
|
42
|
+
## [1.1.66] - (initial changelog entry)
|
|
43
|
+
|
|
44
|
+
- Initial changelog. Prior releases did not include a changelog.
|
|
45
|
+
See git history for changes predating this entry.
|
|
@@ -19,64 +19,18 @@ export declare abstract class BaseEntityProcessor {
|
|
|
19
19
|
inbound(event: EntityPayloadType): Promise<any>;
|
|
20
20
|
handleIncomingUpsert(event: EntityPayloadType): Promise<any>;
|
|
21
21
|
getInboundStatusMessage(statusObject: any): string;
|
|
22
|
-
/** Looks up an identity record from the identity service based on the passed in criteria.
|
|
23
|
-
* If no identity record is found, returns undefined. If multiple are found, throws an error.
|
|
24
|
-
*
|
|
25
|
-
* @param params.poolKey the key to use for the identity service pool. This will be the subtype uniqueness is defined on, typically the root type. Ex: 'item' or 'item:material'
|
|
26
|
-
* @param params.propertyName the name of the property to use for the criteria. Ex: 'itemNumber'
|
|
27
|
-
* @param params.propertyValue the value of the property to use for the criteria. Ex: '12345'
|
|
28
|
-
* @returns the identity entity, or undefined if no identity record is found
|
|
29
|
-
* @throws error if multiple identity entities are found, or if required parameters are missing
|
|
30
|
-
*/
|
|
31
22
|
getIdentityEntity(params: {
|
|
32
23
|
poolKey: string;
|
|
33
24
|
propertyName: string;
|
|
34
25
|
propertyValue: string;
|
|
35
26
|
}): Promise<any | undefined>;
|
|
36
|
-
/** Looks up an entity via the identity service. Uses {@link getIdentityEntity} to find the identity record,
|
|
37
|
-
* then resolves the entity reference to fetch and return the actual entity.
|
|
38
|
-
*
|
|
39
|
-
* @param params.poolKey the key to use for the identity service pool. This will be the subtype uniqueness is defined on, typically the root type. Ex: 'item' or 'item:material'
|
|
40
|
-
* @param params.propertyName the name of the property to use for the criteria. Ex: 'itemNumber'
|
|
41
|
-
* @param params.propertyValue the value of the property to use for the criteria. Ex: '12345'
|
|
42
|
-
* @returns the resolved entity, or undefined if no identity record is found
|
|
43
|
-
* @throws error if multiple identity entities are found, or if required parameters are missing
|
|
44
|
-
*/
|
|
45
27
|
getEntityUsingIdentityService(params: {
|
|
46
28
|
poolKey: string;
|
|
47
29
|
propertyName: string;
|
|
48
30
|
propertyValue: string;
|
|
49
31
|
}): Promise<any | undefined>;
|
|
50
|
-
/**This will query for the entity, and handle post-processing
|
|
51
|
-
* of any critieria that is defined at the sub-type level.
|
|
52
|
-
* Because sub-type criteria can't be used in the search done
|
|
53
|
-
* on the server. This is expected to be called by getIncomingEntity().
|
|
54
|
-
*
|
|
55
|
-
* @param entityType: the root type of the entity
|
|
56
|
-
* @param entityTypePath: the full type path of the entity. Ex: custom-entity:sample
|
|
57
|
-
* @param propertyCriteria: all the criteria to search for the entity
|
|
58
|
-
* @returns the entities that match the criteria
|
|
59
|
-
*/
|
|
60
32
|
queryEntityWithSubTypeCriteria(entityType: string, entityTypePath: string, propertyCriteria: any): Promise<any[]>;
|
|
61
|
-
/** This is to get the criteria for the entity that is being processed.
|
|
62
|
-
* This is to be overridden for item & project-item because of the need for
|
|
63
|
-
* setting the roles criteria.
|
|
64
|
-
*
|
|
65
|
-
* @param entityType: the root type of the entity
|
|
66
|
-
* @param entityTypePath: the full type path of the entity. Ex: custom-entity:sample
|
|
67
|
-
* @param propertyCriteria: all the criteria to search for the entity
|
|
68
|
-
* @returns the criteria for the entity
|
|
69
|
-
*/
|
|
70
33
|
getCriteriaForEntity(entityType: string, entityTypePath: string, propertyCriteria: any): Promise<any>;
|
|
71
|
-
/** This is to get the properties that are owned by the root type
|
|
72
|
-
* This needs to be overridded for multi-level types, such as item
|
|
73
|
-
* and project-item. And for those types, the propertyCriteria
|
|
74
|
-
* will be needed to determine the correct level.
|
|
75
|
-
*
|
|
76
|
-
* @param rootType: the full root type entity for the processed entity
|
|
77
|
-
* @param propertyCriteria: the criteria to determine the correct level (unused for single level types)
|
|
78
|
-
* @returns: string[] of the property keys
|
|
79
|
-
*/
|
|
80
34
|
getRootTypePropertyKeys(rootType: any, propertyCriteria?: any): string[];
|
|
81
35
|
handleIncomingDelete(event: any): Promise<void>;
|
|
82
36
|
getTransformedData(event: any): Promise<any>;
|
|
@@ -92,26 +46,7 @@ export declare abstract class BaseEntityProcessor {
|
|
|
92
46
|
getOutboundEntityUpdates(event: any, flexResponse: any): Promise<any>;
|
|
93
47
|
handleOutgoingDelete(entityType: any, event: any): Promise<void>;
|
|
94
48
|
protected abstract getOutgoingUpsertPayload(entityType: any, event: any): Promise<EntityPayloadType>;
|
|
95
|
-
/** Create a new event-workflow-request to rerun sending the entity to FlexPLM
|
|
96
|
-
* The event must contain any information needed to ensure it is put in the correct queue for the entity
|
|
97
|
-
*
|
|
98
|
-
* @param triggerKey Ex: event.entityType + '|sendUpsertToFlexPLM'
|
|
99
|
-
* @param event
|
|
100
|
-
* @returns
|
|
101
|
-
*/
|
|
102
49
|
protected triggerNewEvent(triggerKey: string, event: any): Promise<any>;
|
|
103
|
-
/** Sends the current state of the entity to FlexPLM.
|
|
104
|
-
* So any changes made in Vibe between the event being generated and the event being processed are sent to FlexPLM.
|
|
105
|
-
*
|
|
106
|
-
* @param event must contain entityType, id; which are used to query for the entity
|
|
107
|
-
* @returns results of sending the entity to FlexPLM
|
|
108
|
-
*/
|
|
109
50
|
protected sendUpsertToFlexPLM(event: any): Promise<any>;
|
|
110
|
-
/** Generates the payload to send to FlexPLM, based on the current state of the entity.
|
|
111
|
-
* The current state of the entity are used as the newData and oldData; which is passed
|
|
112
|
-
* to getOutgoingUpsertPayload to generate the payload.
|
|
113
|
-
* @param event information about the item to send to FlexPLM
|
|
114
|
-
* @returns The payload to send to FlexPLM
|
|
115
|
-
*/
|
|
116
51
|
protected getEntityCurrentStateUpsertPayload(event: any): Promise<EntityPayloadType>;
|
|
117
52
|
}
|
|
@@ -23,7 +23,6 @@ class BaseEntityProcessor {
|
|
|
23
23
|
this.entities = new sdk_1.Entities();
|
|
24
24
|
this.orgSlug = this.config?.orgSlug || 'unset-orgSlug';
|
|
25
25
|
}
|
|
26
|
-
// inbound
|
|
27
26
|
async inbound(event) {
|
|
28
27
|
const eventType = event.eventType;
|
|
29
28
|
console.log(`inbound entity: ${eventType}:${event.objectClass}`);
|
|
@@ -43,7 +42,6 @@ class BaseEntityProcessor {
|
|
|
43
42
|
async handleIncomingUpsert(event) {
|
|
44
43
|
const inboundData = await this.getTransformedData(event);
|
|
45
44
|
const incomingEntityResponse = await this.getIncomingEntity(event, inboundData);
|
|
46
|
-
// This case means there was an early return in the getIncomingEntity method
|
|
47
45
|
if (incomingEntityResponse.earlyReturn) {
|
|
48
46
|
const statusMsg = this.getInboundStatusMessage({
|
|
49
47
|
status: event_short_message_status_1.EventShortMessageStatus.FAILURE,
|
|
@@ -138,15 +136,6 @@ class BaseEntityProcessor {
|
|
|
138
136
|
+ ', federatedId: ' + statusObject.federatedId
|
|
139
137
|
+ ', orgSlug: ' + this.orgSlug;
|
|
140
138
|
}
|
|
141
|
-
/** Looks up an identity record from the identity service based on the passed in criteria.
|
|
142
|
-
* If no identity record is found, returns undefined. If multiple are found, throws an error.
|
|
143
|
-
*
|
|
144
|
-
* @param params.poolKey the key to use for the identity service pool. This will be the subtype uniqueness is defined on, typically the root type. Ex: 'item' or 'item:material'
|
|
145
|
-
* @param params.propertyName the name of the property to use for the criteria. Ex: 'itemNumber'
|
|
146
|
-
* @param params.propertyValue the value of the property to use for the criteria. Ex: '12345'
|
|
147
|
-
* @returns the identity entity, or undefined if no identity record is found
|
|
148
|
-
* @throws error if multiple identity entities are found, or if required parameters are missing
|
|
149
|
-
*/
|
|
150
139
|
async getIdentityEntity(params) {
|
|
151
140
|
const { poolKey, propertyName, propertyValue } = params;
|
|
152
141
|
if (!poolKey || !propertyName || !propertyValue) {
|
|
@@ -168,15 +157,6 @@ class BaseEntityProcessor {
|
|
|
168
157
|
}
|
|
169
158
|
return Array.isArray(identityEntities) ? identityEntities[0] : identityEntities;
|
|
170
159
|
}
|
|
171
|
-
/** Looks up an entity via the identity service. Uses {@link getIdentityEntity} to find the identity record,
|
|
172
|
-
* then resolves the entity reference to fetch and return the actual entity.
|
|
173
|
-
*
|
|
174
|
-
* @param params.poolKey the key to use for the identity service pool. This will be the subtype uniqueness is defined on, typically the root type. Ex: 'item' or 'item:material'
|
|
175
|
-
* @param params.propertyName the name of the property to use for the criteria. Ex: 'itemNumber'
|
|
176
|
-
* @param params.propertyValue the value of the property to use for the criteria. Ex: '12345'
|
|
177
|
-
* @returns the resolved entity, or undefined if no identity record is found
|
|
178
|
-
* @throws error if multiple identity entities are found, or if required parameters are missing
|
|
179
|
-
*/
|
|
180
160
|
async getEntityUsingIdentityService(params) {
|
|
181
161
|
const identityEntity = await this.getIdentityEntity(params);
|
|
182
162
|
if (!identityEntity) {
|
|
@@ -190,18 +170,7 @@ class BaseEntityProcessor {
|
|
|
190
170
|
});
|
|
191
171
|
return entity;
|
|
192
172
|
}
|
|
193
|
-
/**This will query for the entity, and handle post-processing
|
|
194
|
-
* of any critieria that is defined at the sub-type level.
|
|
195
|
-
* Because sub-type criteria can't be used in the search done
|
|
196
|
-
* on the server. This is expected to be called by getIncomingEntity().
|
|
197
|
-
*
|
|
198
|
-
* @param entityType: the root type of the entity
|
|
199
|
-
* @param entityTypePath: the full type path of the entity. Ex: custom-entity:sample
|
|
200
|
-
* @param propertyCriteria: all the criteria to search for the entity
|
|
201
|
-
* @returns the entities that match the criteria
|
|
202
|
-
*/
|
|
203
173
|
async queryEntityWithSubTypeCriteria(entityType, entityTypePath, propertyCriteria) {
|
|
204
|
-
//allCriteria; identifierKeys; entityType; entityTypePath
|
|
205
174
|
if (!entityType || !entityTypePath) {
|
|
206
175
|
throw new Error('type and entityTypePath must be defined');
|
|
207
176
|
}
|
|
@@ -212,15 +181,6 @@ class BaseEntityProcessor {
|
|
|
212
181
|
const returnedEntities = await this.dc.getAllObjectReferences(entityType, rootTypeCriteria, subTypeCriteria);
|
|
213
182
|
return returnedEntities;
|
|
214
183
|
}
|
|
215
|
-
/** This is to get the criteria for the entity that is being processed.
|
|
216
|
-
* This is to be overridden for item & project-item because of the need for
|
|
217
|
-
* setting the roles criteria.
|
|
218
|
-
*
|
|
219
|
-
* @param entityType: the root type of the entity
|
|
220
|
-
* @param entityTypePath: the full type path of the entity. Ex: custom-entity:sample
|
|
221
|
-
* @param propertyCriteria: all the criteria to search for the entity
|
|
222
|
-
* @returns the criteria for the entity
|
|
223
|
-
*/
|
|
224
184
|
async getCriteriaForEntity(entityType, entityTypePath, propertyCriteria) {
|
|
225
185
|
if (!entityType || !entityTypePath) {
|
|
226
186
|
throw new Error('type and entityTypePath must be defined');
|
|
@@ -245,15 +205,6 @@ class BaseEntityProcessor {
|
|
|
245
205
|
}
|
|
246
206
|
return { rootTypeCriteria, subTypeCriteria };
|
|
247
207
|
}
|
|
248
|
-
/** This is to get the properties that are owned by the root type
|
|
249
|
-
* This needs to be overridded for multi-level types, such as item
|
|
250
|
-
* and project-item. And for those types, the propertyCriteria
|
|
251
|
-
* will be needed to determine the correct level.
|
|
252
|
-
*
|
|
253
|
-
* @param rootType: the full root type entity for the processed entity
|
|
254
|
-
* @param propertyCriteria: the criteria to determine the correct level (unused for single level types)
|
|
255
|
-
* @returns: string[] of the property keys
|
|
256
|
-
*/
|
|
257
208
|
getRootTypePropertyKeys(rootType, propertyCriteria = null) {
|
|
258
209
|
const props = rootType['typeProperties'];
|
|
259
210
|
const rootTypePropertyKeys = props.map(prop => prop.slug);
|
|
@@ -286,8 +237,6 @@ class BaseEntityProcessor {
|
|
|
286
237
|
async getVibeOwningKeys(entity) {
|
|
287
238
|
let vibeOwningKeys = [];
|
|
288
239
|
if (this.transformMapFile && entity) {
|
|
289
|
-
//Technically the transform is flex->vibe. But the vibe entity being updated was passed in,
|
|
290
|
-
// so we use VIBE2FLEX_DIRECTION to get the mapKey
|
|
291
240
|
const mapKey = await type_conversion_utils_1.TypeConversionUtils.getMapKey(this.transformMapFile, this.mapFileUtil, entity, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
292
241
|
const mapSection = await map_utils_1.MapUtil.getFullMapSection(this.transformMapFile, this.mapFileUtil, mapKey);
|
|
293
242
|
vibeOwningKeys = mapSection?.vibeOwningKeys || [];
|
|
@@ -322,7 +271,6 @@ class BaseEntityProcessor {
|
|
|
322
271
|
console.log('updateEntity: ' + JSON.stringify(options));
|
|
323
272
|
return await new sdk_1.Entities().update(options);
|
|
324
273
|
}
|
|
325
|
-
// outbound
|
|
326
274
|
async outbound(event) {
|
|
327
275
|
const entityType = event.entityType;
|
|
328
276
|
const eventType = event.eventType;
|
|
@@ -399,13 +347,6 @@ class BaseEntityProcessor {
|
|
|
399
347
|
async handleOutgoingDelete(entityType, event) {
|
|
400
348
|
console.warn('delete is not configured', entityType, event.oldData);
|
|
401
349
|
}
|
|
402
|
-
/** Create a new event-workflow-request to rerun sending the entity to FlexPLM
|
|
403
|
-
* The event must contain any information needed to ensure it is put in the correct queue for the entity
|
|
404
|
-
*
|
|
405
|
-
* @param triggerKey Ex: event.entityType + '|sendUpsertToFlexPLM'
|
|
406
|
-
* @param event
|
|
407
|
-
* @returns
|
|
408
|
-
*/
|
|
409
350
|
async triggerNewEvent(triggerKey, event) {
|
|
410
351
|
const newEvent = {
|
|
411
352
|
entityName: 'event-workflow-request',
|
|
@@ -417,12 +358,6 @@ class BaseEntityProcessor {
|
|
|
417
358
|
const response = await this.entities.create(newEvent);
|
|
418
359
|
return response;
|
|
419
360
|
}
|
|
420
|
-
/** Sends the current state of the entity to FlexPLM.
|
|
421
|
-
* So any changes made in Vibe between the event being generated and the event being processed are sent to FlexPLM.
|
|
422
|
-
*
|
|
423
|
-
* @param event must contain entityType, id; which are used to query for the entity
|
|
424
|
-
* @returns results of sending the entity to FlexPLM
|
|
425
|
-
*/
|
|
426
361
|
async sendUpsertToFlexPLM(event) {
|
|
427
362
|
const payload = await this.getEntityCurrentStateUpsertPayload(event);
|
|
428
363
|
if (!payload) {
|
|
@@ -463,12 +398,6 @@ class BaseEntityProcessor {
|
|
|
463
398
|
throw e;
|
|
464
399
|
}
|
|
465
400
|
}
|
|
466
|
-
/** Generates the payload to send to FlexPLM, based on the current state of the entity.
|
|
467
|
-
* The current state of the entity are used as the newData and oldData; which is passed
|
|
468
|
-
* to getOutgoingUpsertPayload to generate the payload.
|
|
469
|
-
* @param event information about the item to send to FlexPLM
|
|
470
|
-
* @returns The payload to send to FlexPLM
|
|
471
|
-
*/
|
|
472
401
|
async getEntityCurrentStateUpsertPayload(event) {
|
|
473
402
|
const id = event.id;
|
|
474
403
|
if (!id) {
|
|
@@ -269,7 +269,6 @@ describe('BaseEntityProcessor', () => {
|
|
|
269
269
|
const rootCriteriaResults = Object.assign({}, rootCriteria);
|
|
270
270
|
const subCriteriaResults = Object.assign({}, subCriteria);
|
|
271
271
|
const mockGetByRootTypeProperties = jest.spyOn(btep, 'getRootTypePropertyKeys').mockReturnValue(['rootText']);
|
|
272
|
-
// const mockDCgetAllObjectReferences = jest.spyOn(dc, 'getAllObjectReferences').mockReturnValue(Promise.resolve([]));
|
|
273
272
|
const { rootTypeCriteria, subTypeCriteria } = await btep.getCriteriaForEntity(entityType, entityTypePath, propertyCriteria);
|
|
274
273
|
expect(mockTypeUtilGetByRootAndPath).toBeCalledTimes(1);
|
|
275
274
|
expect(mockTypeUtilGetByRootAndPath).toBeCalledWith({ root: entityType });
|
package/lib/index.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ export * from './util/map-utils';
|
|
|
16
16
|
export * from './interfaces/interfaces';
|
|
17
17
|
export * from './interfaces/item-family-changes';
|
|
18
18
|
export * from './interfaces/publish-change-data';
|
|
19
|
-
export * from './interfaces/mapping-file';
|
|
20
19
|
export * from './publish/base-process-publish-assortment';
|
|
21
20
|
export * from './publish/base-process-publish-assortment-callback';
|
|
22
21
|
export * from './entity-processor/base-entity-processor';
|
package/lib/index.js
CHANGED
|
@@ -32,7 +32,6 @@ __exportStar(require("./util/map-utils"), exports);
|
|
|
32
32
|
__exportStar(require("./interfaces/interfaces"), exports);
|
|
33
33
|
__exportStar(require("./interfaces/item-family-changes"), exports);
|
|
34
34
|
__exportStar(require("./interfaces/publish-change-data"), exports);
|
|
35
|
-
__exportStar(require("./interfaces/mapping-file"), exports);
|
|
36
35
|
__exportStar(require("./publish/base-process-publish-assortment"), exports);
|
|
37
36
|
__exportStar(require("./publish/base-process-publish-assortment-callback"), exports);
|
|
38
37
|
__exportStar(require("./entity-processor/base-entity-processor"), exports);
|
|
@@ -32,15 +32,6 @@ export declare class BaseProcessPublishAssortment {
|
|
|
32
32
|
skip_await?: undefined;
|
|
33
33
|
}>;
|
|
34
34
|
getPublishInfo(assortmentId: string, assortmentPublishChangeId: string, apcHistory: any, publisher: any): Promise<any>;
|
|
35
|
-
/** Gets the version number of the snapshot that was created for the publish change.
|
|
36
|
-
* But if no snapshot was found for the publish change, and the last snapshot was
|
|
37
|
-
* created before the publish change, then it returns 'after: versionNumber' where
|
|
38
|
-
* versionNumber is the version number of the last snapshot.
|
|
39
|
-
* If no snapshot was found for the publish change, and the last snapshot was
|
|
40
|
-
* created after the publish change, then it returns 'unknown'.
|
|
41
|
-
*
|
|
42
|
-
* @returns versionNumber or 'unknown' or 'after: versionNumber'
|
|
43
|
-
*/
|
|
44
35
|
getSnapshotVersion(assortment: any, apc: any): Promise<number | string>;
|
|
45
36
|
getSeasonFederation(assortmentId: any): Promise<SeasonFederation>;
|
|
46
37
|
getAssortment(assortmentId: any): Promise<any>;
|
|
@@ -91,22 +82,6 @@ export declare class BaseProcessPublishAssortment {
|
|
|
91
82
|
private getCurrentDateString;
|
|
92
83
|
getItemFamilyChanges(pcd: PublishChangeData, changeDetail: any, assortmentItemFullChangeMap: Map<string, any>, assortmentItemDeleteMap: Map<string, any>): Map<string, ItemFamilyChanges>;
|
|
93
84
|
getEventsForPublishChangeData(publishChangeData: PublishChangeData): Promise<SeasonalPayload[]>;
|
|
94
|
-
/**Returns the events for a given ItemFamilyChanges object
|
|
95
|
-
*
|
|
96
|
-
* Cases:
|
|
97
|
-
* Add just family:
|
|
98
|
-
* Add option to family (with existing option):
|
|
99
|
-
* Add option to family (no options on assortment):
|
|
100
|
-
* Remove family and option:
|
|
101
|
-
* Remove only option and leave family:
|
|
102
|
-
* Remove one option of multiple for family:
|
|
103
|
-
*
|
|
104
|
-
* @param itemFamilyChanges
|
|
105
|
-
* @param assortmentId
|
|
106
|
-
* @param assortmentFederationId
|
|
107
|
-
* @param itemToFederatedIdMapping
|
|
108
|
-
* @returns
|
|
109
|
-
*/
|
|
110
85
|
getEventsForItemFamilyChanges(itemFamilyChanges: ItemFamilyChanges, assortmentId: string, seasonFed: SeasonFederation, itemToFederatedIdMapping: Map<string, string>): Promise<SeasonalPayload[]>;
|
|
111
86
|
getProjectItem(itemFamilyChanges: ItemFamilyChanges, id: string): any;
|
|
112
87
|
getSeasonalData(projectItem: any): Promise<object>;
|