@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.
Files changed (111) hide show
  1. package/.github/pull_request_template.md +31 -0
  2. package/.github/workflows/flexplm-lib.yml +27 -0
  3. package/.github/workflows/publish-to-npm.yml +121 -0
  4. package/CHANGELOG.md +45 -0
  5. package/lib/entity-processor/base-entity-processor.d.ts +0 -65
  6. package/lib/entity-processor/base-entity-processor.js +0 -71
  7. package/lib/entity-processor/base-entity-processor.spec.js +0 -1
  8. package/lib/index.d.ts +0 -1
  9. package/lib/index.js +0 -1
  10. package/lib/publish/base-process-publish-assortment.d.ts +0 -25
  11. package/lib/publish/base-process-publish-assortment.js +6 -60
  12. package/lib/publish/base-process-publish-assortment.spec.js +4 -22
  13. package/lib/publish/mockData.js +0 -5
  14. package/lib/transform/identifier-conversion-spec-mockData.js +6 -34
  15. package/lib/transform/identifier-conversion.d.ts +0 -36
  16. package/lib/transform/identifier-conversion.js +0 -36
  17. package/lib/transform/identifier-conversion.spec.js +0 -4
  18. package/lib/util/config-defaults.js +0 -3
  19. package/lib/util/config-defaults.spec.js +0 -9
  20. package/lib/util/data-converter-spec-mockData.js +3 -17
  21. package/lib/util/data-converter.d.ts +0 -97
  22. package/lib/util/data-converter.js +1 -127
  23. package/lib/util/data-converter.spec.js +0 -2
  24. package/lib/util/error-response-object.d.ts +0 -5
  25. package/lib/util/error-response-object.js +0 -7
  26. package/lib/util/event-short-message-status.js +0 -1
  27. package/lib/util/federation.js +0 -8
  28. package/lib/util/flexplm-connect.d.ts +0 -7
  29. package/lib/util/flexplm-connect.js +0 -14
  30. package/lib/util/logger-config.js +0 -1
  31. package/lib/util/map-util-spec-mockData.js +3 -17
  32. package/lib/util/map-utils.d.ts +0 -27
  33. package/lib/util/map-utils.js +0 -27
  34. package/lib/util/thumbnail-util.d.ts +0 -21
  35. package/lib/util/thumbnail-util.js +1 -28
  36. package/lib/util/thumbnail-util.spec.js +0 -6
  37. package/lib/util/type-conversion-utils-spec-mockData.js +3 -3
  38. package/lib/util/type-conversion-utils.d.ts +1 -152
  39. package/lib/util/type-conversion-utils.js +1 -155
  40. package/lib/util/type-defaults.d.ts +0 -66
  41. package/lib/util/type-defaults.js +0 -66
  42. package/lib/util/type-defaults.spec.js +5 -5
  43. package/lib/util/type-utils.d.ts +0 -21
  44. package/lib/util/type-utils.js +0 -23
  45. package/lib/util/type-utils.spec.js +0 -2
  46. package/package.json +6 -21
  47. package/publish.bat +5 -0
  48. package/publish.sh +5 -0
  49. package/src/entity-processor/base-entity-processor.spec.ts +689 -0
  50. package/src/entity-processor/base-entity-processor.ts +583 -0
  51. package/src/flexplm-request.ts +28 -0
  52. package/src/flexplm-utils.spec.ts +27 -0
  53. package/src/flexplm-utils.ts +29 -0
  54. package/src/index.ts +22 -0
  55. package/src/interfaces/interfaces.ts +122 -0
  56. package/src/interfaces/item-family-changes.ts +67 -0
  57. package/src/interfaces/publish-change-data.ts +43 -0
  58. package/src/publish/base-process-publish-assortment-callback.ts +50 -0
  59. package/src/publish/base-process-publish-assortment.spec.ts +1992 -0
  60. package/src/publish/base-process-publish-assortment.ts +1134 -0
  61. package/src/publish/mockData.ts +4561 -0
  62. package/src/transform/identifier-conversion-spec-mockData.ts +496 -0
  63. package/src/transform/identifier-conversion.spec.ts +386 -0
  64. package/src/transform/identifier-conversion.ts +282 -0
  65. package/src/util/config-defaults.spec.ts +445 -0
  66. package/src/util/config-defaults.ts +106 -0
  67. package/src/util/data-converter-spec-mockData.ts +231 -0
  68. package/src/util/data-converter.spec.ts +1622 -0
  69. package/src/util/data-converter.ts +819 -0
  70. package/src/util/error-response-object.spec.ts +116 -0
  71. package/src/util/error-response-object.ts +50 -0
  72. package/src/util/event-short-message-status.ts +22 -0
  73. package/src/util/federation.ts +172 -0
  74. package/src/util/flexplm-connect.spec.ts +132 -0
  75. package/src/util/flexplm-connect.ts +208 -0
  76. package/src/util/logger-config.ts +20 -0
  77. package/src/util/map-util-spec-mockData.ts +231 -0
  78. package/src/util/map-utils.spec.ts +103 -0
  79. package/src/util/map-utils.ts +41 -0
  80. package/src/util/mockData.ts +101 -0
  81. package/src/util/thumbnail-util.spec.ts +508 -0
  82. package/src/util/thumbnail-util.ts +272 -0
  83. package/src/util/type-conversion-utils-spec-mockData.ts +272 -0
  84. package/src/util/type-conversion-utils.spec.ts +1031 -0
  85. package/src/util/type-conversion-utils.ts +490 -0
  86. package/src/util/type-defaults.spec.ts +797 -0
  87. package/src/util/type-defaults.ts +320 -0
  88. package/src/util/type-utils.spec.ts +227 -0
  89. package/src/util/type-utils.ts +144 -0
  90. package/tsconfig.json +24 -0
  91. package/tslint.json +57 -0
  92. package/lib/cli/commands/compile.d.ts +0 -4
  93. package/lib/cli/commands/compile.js +0 -73
  94. package/lib/cli/commands/compile.spec.d.ts +0 -1
  95. package/lib/cli/commands/compile.spec.js +0 -80
  96. package/lib/cli/commands/create.d.ts +0 -5
  97. package/lib/cli/commands/create.js +0 -77
  98. package/lib/cli/commands/create.spec.d.ts +0 -1
  99. package/lib/cli/commands/create.spec.js +0 -78
  100. package/lib/cli/commands/upload.d.ts +0 -17
  101. package/lib/cli/commands/upload.js +0 -228
  102. package/lib/cli/commands/upload.spec.d.ts +0 -1
  103. package/lib/cli/commands/upload.spec.js +0 -88
  104. package/lib/cli/index.d.ts +0 -5
  105. package/lib/cli/index.js +0 -70
  106. package/lib/cli/index.spec.d.ts +0 -1
  107. package/lib/cli/index.spec.js +0 -85
  108. package/lib/cli/template/mapping-template.ts.template +0 -62
  109. package/lib/interfaces/mapping-file.d.ts +0 -460
  110. package/lib/interfaces/mapping-file.js +0 -2
  111. package/scripts/copy-template.js +0 -10
@@ -1,88 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- jest.mock('@contrail/sdk', () => ({
4
- Entities: jest.fn(),
5
- Files: jest.fn(),
6
- login: jest.fn(),
7
- }));
8
- const upload_1 = require("./upload");
9
- describe('UploadCommand.parseArgs', () => {
10
- it('parses a bare file path', () => {
11
- const opts = upload_1.UploadCommand.parseArgs(['mapping.ts']);
12
- expect(opts).toEqual({
13
- filePath: 'mapping.ts',
14
- message: undefined,
15
- branch: undefined,
16
- skipGit: false,
17
- });
18
- });
19
- it('parses -m commit message option', () => {
20
- const opts = upload_1.UploadCommand.parseArgs(['mapping.ts', '-m', 'my message']);
21
- expect(opts.message).toEqual('my message');
22
- expect(opts.skipGit).toBe(false);
23
- });
24
- it('parses -b branch option', () => {
25
- const opts = upload_1.UploadCommand.parseArgs(['mapping.ts', '-b', 'feature/x']);
26
- expect(opts.branch).toEqual('feature/x');
27
- });
28
- it('parses --skip-git flag', () => {
29
- const opts = upload_1.UploadCommand.parseArgs(['mapping.ts', '--skip-git']);
30
- expect(opts.skipGit).toBe(true);
31
- });
32
- it('accepts the legacy --skipGit alias', () => {
33
- const opts = upload_1.UploadCommand.parseArgs(['mapping.ts', '--skipGit']);
34
- expect(opts.skipGit).toBe(true);
35
- });
36
- it('parses options before the file path', () => {
37
- const opts = upload_1.UploadCommand.parseArgs(['-m', 'msg', '-b', 'br', 'mapping.ts']);
38
- expect(opts).toEqual({
39
- filePath: 'mapping.ts',
40
- message: 'msg',
41
- branch: 'br',
42
- skipGit: false,
43
- });
44
- });
45
- it('parses all options together', () => {
46
- const opts = upload_1.UploadCommand.parseArgs(['mapping.ts', '-m', 'msg', '-b', 'br', '--skip-git']);
47
- expect(opts).toEqual({
48
- filePath: 'mapping.ts',
49
- message: 'msg',
50
- branch: 'br',
51
- skipGit: true,
52
- });
53
- });
54
- it('throws when -m is missing its value', () => {
55
- expect(() => upload_1.UploadCommand.parseArgs(['mapping.ts', '-m'])).toThrow(/-m requires a commit message/);
56
- });
57
- it('throws when -b is missing its value', () => {
58
- expect(() => upload_1.UploadCommand.parseArgs(['mapping.ts', '-b'])).toThrow(/-b requires a branch name/);
59
- });
60
- it('throws on unknown option', () => {
61
- expect(() => upload_1.UploadCommand.parseArgs(['mapping.ts', '--bogus'])).toThrow(/Unknown option: --bogus/);
62
- });
63
- it('throws when an extra positional argument is supplied', () => {
64
- expect(() => upload_1.UploadCommand.parseArgs(['mapping.ts', 'extra.ts'])).toThrow(/Unexpected argument: extra\.ts/);
65
- });
66
- it('throws when no file path is provided', () => {
67
- expect(() => upload_1.UploadCommand.parseArgs([])).toThrow(/missing <path\.ts>/);
68
- });
69
- it('throws when only options are provided', () => {
70
- expect(() => upload_1.UploadCommand.parseArgs(['--skip-git'])).toThrow(/missing <path\.ts>/);
71
- });
72
- });
73
- describe('UploadCommand.buildCommitMessage', () => {
74
- it('appends fileId to the first line of a single-line message', () => {
75
- expect(upload_1.UploadCommand.buildCommitMessage('initial commit', 'abc123')).toEqual('initial commit [fileId: abc123]');
76
- });
77
- it('only appends fileId to the first line of a multi-line message', () => {
78
- const result = upload_1.UploadCommand.buildCommitMessage('header line\nbody line 1\nbody line 2', 'xyz');
79
- expect(result).toEqual('header line [fileId: xyz]\nbody line 1\nbody line 2');
80
- });
81
- it('handles CRLF line endings', () => {
82
- const result = upload_1.UploadCommand.buildCommitMessage('header\r\nbody', 'fid');
83
- expect(result).toEqual('header [fileId: fid]\nbody');
84
- });
85
- it('handles an empty message', () => {
86
- expect(upload_1.UploadCommand.buildCommitMessage('', 'fid')).toEqual(' [fileId: fid]');
87
- });
88
- });
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- export declare class Cli {
3
- main(): Promise<void>;
4
- }
5
- export declare function main(): Promise<void>;
package/lib/cli/index.js DELETED
@@ -1,70 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.main = exports.Cli = void 0;
5
- const create_1 = require("./commands/create");
6
- const compile_1 = require("./commands/compile");
7
- const upload_1 = require("./commands/upload");
8
- const USAGE = `Usage: flexplm-mapping <command> [args]
9
-
10
- Commands:
11
- create Scaffold a new mapping .ts file in the current directory
12
- compile <path.ts> Transpile a mapping .ts file to .js alongside it
13
- upload <path.ts> [opts] Compile a mapping .ts file and upload the resulting .js to VibeIQ
14
-
15
- Upload options:
16
- -m <message> Git commit message (prompted if omitted)
17
- -b <branch> Create a new git branch before committing
18
- --skip-git Skip the post-upload git commit (default: commit)
19
-
20
- Environment (upload):
21
- CONTRAIL_CLI_EMAIL VibeIQ user email
22
- CONTRAIL_CLI_PASSWORD VibeIQ user password
23
- `;
24
- class Cli {
25
- async main() {
26
- const [, , command, ...rest] = process.argv;
27
- switch (command) {
28
- case 'create':
29
- await new create_1.CreateCommand().run();
30
- return;
31
- case 'compile':
32
- if (!rest[0]) {
33
- console.error('compile: missing <path.ts> argument');
34
- console.error(USAGE);
35
- process.exit(1);
36
- }
37
- await new compile_1.CompileCommand().run(rest[0]);
38
- return;
39
- case 'upload':
40
- if (!rest[0]) {
41
- console.error('upload: missing <path.ts> argument');
42
- console.error(USAGE);
43
- process.exit(1);
44
- }
45
- await new upload_1.UploadCommand().run(rest);
46
- return;
47
- case undefined:
48
- case '-h':
49
- case '--help':
50
- case 'help':
51
- console.log(USAGE);
52
- return;
53
- default:
54
- console.error(`Unknown command: ${command}`);
55
- console.error(USAGE);
56
- process.exit(1);
57
- }
58
- }
59
- }
60
- exports.Cli = Cli;
61
- function main() {
62
- return new Cli().main();
63
- }
64
- exports.main = main;
65
- if (require.main === module) {
66
- main().catch((err) => {
67
- console.error(err && err.message ? err.message : err);
68
- process.exit(1);
69
- });
70
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const createRunMock = jest.fn().mockResolvedValue(undefined);
4
- const compileRunMock = jest.fn().mockResolvedValue(undefined);
5
- const uploadRunMock = jest.fn().mockResolvedValue(undefined);
6
- jest.mock('./commands/create', () => ({
7
- CreateCommand: jest.fn().mockImplementation(() => ({ run: createRunMock })),
8
- }));
9
- jest.mock('./commands/compile', () => ({
10
- CompileCommand: jest.fn().mockImplementation(() => ({ run: compileRunMock })),
11
- }));
12
- jest.mock('./commands/upload', () => ({
13
- UploadCommand: jest.fn().mockImplementation(() => ({ run: uploadRunMock })),
14
- }));
15
- const index_1 = require("./index");
16
- describe('cli main dispatcher', () => {
17
- let originalArgv;
18
- let logSpy;
19
- let errorSpy;
20
- let exitSpy;
21
- beforeEach(() => {
22
- originalArgv = process.argv;
23
- createRunMock.mockClear();
24
- compileRunMock.mockClear();
25
- uploadRunMock.mockClear();
26
- logSpy = jest.spyOn(console, 'log').mockImplementation(() => { });
27
- errorSpy = jest.spyOn(console, 'error').mockImplementation(() => { });
28
- exitSpy = jest.spyOn(process, 'exit').mockImplementation(((code) => {
29
- throw new Error(`__EXIT__:${code}`);
30
- }));
31
- });
32
- afterEach(() => {
33
- process.argv = originalArgv;
34
- logSpy.mockRestore();
35
- errorSpy.mockRestore();
36
- exitSpy.mockRestore();
37
- });
38
- function setArgv(...args) {
39
- process.argv = ['node', 'cli', ...args];
40
- }
41
- it('dispatches the create command', async () => {
42
- setArgv('create');
43
- await (0, index_1.main)();
44
- expect(createRunMock).toHaveBeenCalledTimes(1);
45
- expect(compileRunMock).not.toHaveBeenCalled();
46
- expect(uploadRunMock).not.toHaveBeenCalled();
47
- });
48
- it('dispatches the compile command with its argument', async () => {
49
- setArgv('compile', 'mapping.ts');
50
- await (0, index_1.main)();
51
- expect(compileRunMock).toHaveBeenCalledWith('mapping.ts');
52
- });
53
- it('exits when compile is missing its argument', async () => {
54
- setArgv('compile');
55
- await expect((0, index_1.main)()).rejects.toThrow('__EXIT__:1');
56
- expect(compileRunMock).not.toHaveBeenCalled();
57
- expect(errorSpy).toHaveBeenCalledWith(expect.stringMatching(/missing <path\.ts>/));
58
- });
59
- it('dispatches the upload command and forwards remaining args', async () => {
60
- setArgv('upload', 'mapping.ts', '-m', 'msg', '--skip-git');
61
- await (0, index_1.main)();
62
- expect(uploadRunMock).toHaveBeenCalledWith(['mapping.ts', '-m', 'msg', '--skip-git']);
63
- });
64
- it('exits when upload is missing its argument', async () => {
65
- setArgv('upload');
66
- await expect((0, index_1.main)()).rejects.toThrow('__EXIT__:1');
67
- expect(uploadRunMock).not.toHaveBeenCalled();
68
- expect(errorSpy).toHaveBeenCalledWith(expect.stringMatching(/missing <path\.ts>/));
69
- });
70
- it.each(['help', '-h', '--help'])('prints usage for %s', async (helpFlag) => {
71
- setArgv(helpFlag);
72
- await (0, index_1.main)();
73
- expect(logSpy).toHaveBeenCalledWith(expect.stringMatching(/Usage: flexplm-mapping/));
74
- });
75
- it('prints usage when no command is provided', async () => {
76
- setArgv();
77
- await (0, index_1.main)();
78
- expect(logSpy).toHaveBeenCalledWith(expect.stringMatching(/Usage: flexplm-mapping/));
79
- });
80
- it('exits on an unknown command', async () => {
81
- setArgv('bogus');
82
- await expect((0, index_1.main)()).rejects.toThrow('__EXIT__:1');
83
- expect(errorSpy).toHaveBeenCalledWith(expect.stringMatching(/Unknown command: bogus/));
84
- });
85
- });
@@ -1,62 +0,0 @@
1
- import type { MappingFile } from '@contrail/flexplm';
2
-
3
- export const mapping: MappingFile = {
4
- orgInfo: {
5
- appIdentifier: '@vibeiq/flexplm-connector',
6
- orgName: '<ORG_NAME>',
7
- },
8
- typeConversion: {
9
- vibe2flex: {},
10
- flex2vibe: {},
11
- },
12
- LCSSeason: {
13
- vibeOwningKeys: ['flexPLMSeasonName'],
14
- vibe2flex: {
15
- transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }],
16
- rekey: {
17
- seasonName: 'flexPLMSeasonName',
18
- },
19
- },
20
- flex2vibe: {
21
- transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }],
22
- rekey: {
23
- flexPLMSeasonName: 'seasonName',
24
- },
25
- },
26
- },
27
- LCSProduct: {
28
- vibeOwningKeys: ['itemNumber'],
29
- vibe2flex: {
30
- transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }],
31
- rekey: {
32
- vibeIQIdentifier: 'itemNumber',
33
- productName: 'name',
34
- },
35
- },
36
- flex2vibe: {
37
- transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }],
38
- rekey: {
39
- itemNumber: 'vibeIQIdentifier',
40
- name: 'productName',
41
- },
42
- },
43
- },
44
- LCSSKU: {
45
- vibeOwningKeys: ['itemNumber'],
46
- vibe2flex: {
47
- transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }],
48
- rekey: {
49
- vibeIQIdentifier: 'itemNumber',
50
- skuName: 'optionName',
51
- },
52
- },
53
- flex2vibe: {
54
- transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }],
55
- rekey: {
56
- itemNumber: 'vibeIQIdentifier',
57
- optionName: 'skuName',
58
- },
59
- },
60
- },
61
-
62
- };