trm-core 6.2.3 → 6.2.4

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.
@@ -7,10 +7,13 @@ export declare class TrmArtifact {
7
7
  private _distFolder?;
8
8
  private _manifest?;
9
9
  private _zip;
10
+ private _binaries;
11
+ private _content;
10
12
  constructor(binary: Buffer, _distFolder?: string, _manifest?: Manifest);
11
13
  getManifest(): Manifest | null;
12
14
  replaceManifest(oManifest: Manifest): void;
13
15
  getDistFolder(): string | null;
14
16
  getTransportBinaries(r3transOption?: R3transOptions): Promise<TransportBinary[]>;
17
+ getContent(r3transConfig?: R3transOptions): Promise<any>;
15
18
  static create(transports: Transport[], manifest: Manifest, distFolder?: string): Promise<TrmArtifact>;
16
19
  }
@@ -92,37 +92,71 @@ class TrmArtifact {
92
92
  getTransportBinaries(r3transOption) {
93
93
  return __awaiter(this, void 0, void 0, function* () {
94
94
  var _a, _b;
95
- const distFolder = this.getDistFolder();
96
- if (!distFolder) {
97
- throw new Error(`Couldn't locate dist folder.`);
95
+ if (!this._binaries) {
96
+ const distFolder = this.getDistFolder();
97
+ if (!distFolder) {
98
+ throw new Error(`Couldn't locate dist folder.`);
99
+ }
100
+ const zipEntries = this._zip.getEntries();
101
+ const aTransportEntries = zipEntries.filter(o => (new RegExp(`^${distFolder}(/|\\\\)`)).test(o.entryName.trim().toLowerCase()));
102
+ var aResult = [];
103
+ const r3trans = new node_r3trans_1.R3trans(r3transOption);
104
+ for (const entry of aTransportEntries) {
105
+ try {
106
+ const type = entry.comment;
107
+ const oPackedTransport = new AdmZip.default(entry.getData());
108
+ const aPackedTransportEntries = oPackedTransport.getEntries();
109
+ const oHeader = (_a = aPackedTransportEntries.find(o => o.comment === 'header')) === null || _a === void 0 ? void 0 : _a.getData();
110
+ const oData = (_b = aPackedTransportEntries.find(o => o.comment === 'data')) === null || _b === void 0 ? void 0 : _b.getData();
111
+ if (oHeader && oData) {
112
+ const trkorr = yield r3trans.getTransportTrkorr(oData);
113
+ aResult.push({
114
+ trkorr,
115
+ type: type,
116
+ binaries: {
117
+ header: oHeader,
118
+ data: oData
119
+ }
120
+ });
121
+ }
122
+ }
123
+ catch (e) { }
124
+ }
125
+ ;
126
+ this._binaries = aResult;
98
127
  }
99
- const zipEntries = this._zip.getEntries();
100
- const aTransportEntries = zipEntries.filter(o => (new RegExp(`^${distFolder}(/|\\\\)`)).test(o.entryName.trim().toLowerCase()));
101
- var aResult = [];
102
- const r3trans = new node_r3trans_1.R3trans(r3transOption);
103
- for (const entry of aTransportEntries) {
128
+ return this._binaries || [];
129
+ });
130
+ }
131
+ getContent(r3transConfig) {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ if (!this._content) {
134
+ this._content = {};
104
135
  try {
105
- const type = entry.comment;
106
- const oPackedTransport = new AdmZip.default(entry.getData());
107
- const aPackedTransportEntries = oPackedTransport.getEntries();
108
- const oHeader = (_a = aPackedTransportEntries.find(o => o.comment === 'header')) === null || _a === void 0 ? void 0 : _a.getData();
109
- const oData = (_b = aPackedTransportEntries.find(o => o.comment === 'data')) === null || _b === void 0 ? void 0 : _b.getData();
110
- if (oHeader && oData) {
111
- const trkorr = yield r3trans.getTransportTrkorr(oData);
112
- aResult.push({
113
- trkorr,
114
- type,
115
- binaries: {
116
- header: oHeader,
117
- data: oData
136
+ const transportBinaries = yield this.getTransportBinaries();
137
+ const r3trans = new node_r3trans_1.R3trans(r3transConfig);
138
+ for (const transportBinary of transportBinaries) {
139
+ const tableEntries = yield r3trans.getTableEntries(transportBinary.binaries.data);
140
+ if (!this._content[transportBinary.type]) {
141
+ this._content[transportBinary.type] = {
142
+ trkorr: transportBinary.trkorr,
143
+ content: {}
144
+ };
145
+ }
146
+ Object.keys(tableEntries).forEach(table => {
147
+ if (!this._content[transportBinary.type].content[table]) {
148
+ this._content[transportBinary.type].content[table] = [];
118
149
  }
150
+ this._content[transportBinary.type].content[table] = this._content[transportBinary.type].content[table].concat(tableEntries[table]);
119
151
  });
120
152
  }
121
153
  }
122
- catch (e) { }
154
+ catch (e) {
155
+ delete this._content;
156
+ throw e;
157
+ }
123
158
  }
124
- ;
125
- return aResult;
159
+ return this._content || {};
126
160
  });
127
161
  }
128
162
  static create(transports_1, manifest_2) {
@@ -2,6 +2,7 @@ import { Manifest } from "../manifest";
2
2
  import { Registry } from "../registry";
3
3
  import { TrmArtifact } from "./TrmArtifact";
4
4
  import { DEVCLASS } from "../client";
5
+ import { R3transOptions } from "node-r3trans";
5
6
  export declare const DEFAULT_VERSION: string;
6
7
  export declare class TrmPackage {
7
8
  packageName: string;
@@ -10,6 +11,7 @@ export declare class TrmPackage {
10
11
  private _userAuthorizations;
11
12
  private _canPublishReleasesCause;
12
13
  private _remoteArtifacts;
14
+ private _remoteContent;
13
15
  private _devclass;
14
16
  constructor(packageName: string, registry: Registry, manifest?: Manifest);
15
17
  setDevclass(devclass: DEVCLASS): TrmPackage;
@@ -19,8 +21,9 @@ export declare class TrmPackage {
19
21
  canPublishReleases: boolean;
20
22
  cause?: string;
21
23
  }>;
22
- fetchRemoteManifest(version?: string): Promise<Manifest>;
23
24
  fetchRemoteArtifact(version?: string): Promise<TrmArtifact>;
25
+ fetchRemoteManifest(version?: string): Promise<Manifest>;
26
+ fetchRemoteContent(version?: string, r3transConfig?: R3transOptions): Promise<any>;
24
27
  publish(data: {
25
28
  artifact: TrmArtifact;
26
29
  readme?: string;
@@ -54,6 +54,7 @@ class TrmPackage {
54
54
  this.registry = registry;
55
55
  this.manifest = manifest;
56
56
  this._remoteArtifacts = {};
57
+ this._remoteContent = {};
57
58
  }
58
59
  setDevclass(devclass) {
59
60
  this._devclass = devclass;
@@ -91,21 +92,30 @@ class TrmPackage {
91
92
  };
92
93
  });
93
94
  }
94
- fetchRemoteManifest() {
95
+ fetchRemoteArtifact() {
95
96
  return __awaiter(this, arguments, void 0, function* (version = 'latest') {
96
97
  if (!this._remoteArtifacts[version]) {
97
- const artifact = yield this.registry.getArtifact(this.packageName, version);
98
- this._remoteArtifacts[version] = artifact;
98
+ this._remoteArtifacts[version] = yield this.registry.getArtifact(this.packageName, version);
99
99
  }
100
- this.manifest = this._remoteArtifacts[version].getManifest();
100
+ return this._remoteArtifacts[version];
101
+ });
102
+ }
103
+ fetchRemoteManifest() {
104
+ return __awaiter(this, arguments, void 0, function* (version = 'latest') {
105
+ const artifact = yield this.fetchRemoteArtifact(version);
106
+ this.manifest = artifact.getManifest();
101
107
  this._remoteArtifacts[this.manifest.get().version] = this._remoteArtifacts[version];
102
108
  return this._remoteArtifacts[version].getManifest();
103
109
  });
104
110
  }
105
- fetchRemoteArtifact() {
106
- return __awaiter(this, arguments, void 0, function* (version = 'latest') {
107
- if (!this._remoteArtifacts[version]) {
108
- this._remoteArtifacts[version] = yield this.registry.getArtifact(this.packageName, version);
111
+ fetchRemoteContent() {
112
+ return __awaiter(this, arguments, void 0, function* (version = 'latest', r3transConfig) {
113
+ if (!this._remoteContent[version]) {
114
+ const artifact = yield this.fetchRemoteArtifact(version);
115
+ const manifest = artifact.getManifest();
116
+ const actualVersion = manifest.get().version;
117
+ this._remoteArtifacts[version] = yield artifact.getContent(r3transConfig);
118
+ this._remoteArtifacts[actualVersion] = this._remoteArtifacts[version];
109
119
  }
110
120
  return this._remoteArtifacts[version];
111
121
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trm-core",
3
- "version": "6.2.3",
3
+ "version": "6.2.4",
4
4
  "description": "TRM (Transport Request Manager) Core",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",