@degenerate/generic 0.0.10 → 0.0.13

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.
@@ -1,6 +1,7 @@
1
1
  export * from './base-error';
2
2
  export * from './generic/generic-errors';
3
3
  export * from './request/request-errors';
4
+ export * from './safe/safe-rules-errors';
4
5
  export * from './scheduler/scheduler-errors';
5
6
  export * from './share-data/share-data-errors';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC"}
@@ -17,5 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./base-error"), exports);
18
18
  __exportStar(require("./generic/generic-errors"), exports);
19
19
  __exportStar(require("./request/request-errors"), exports);
20
+ __exportStar(require("./safe/safe-rules-errors"), exports);
20
21
  __exportStar(require("./scheduler/scheduler-errors"), exports);
21
22
  __exportStar(require("./share-data/share-data-errors"), exports);
@@ -0,0 +1,30 @@
1
+ import { ConditionType } from '../../models';
2
+ import { BaseError } from '../base-error';
3
+ /**
4
+ * This error is thrown when a evaluation condition data value is not valid
5
+ */
6
+ export declare class SafeRuleEvaluationConditionDataValueError extends BaseError {
7
+ /**
8
+ * This error is thrown when a evaluation condition data value is not valid
9
+ */
10
+ constructor(dataValue: unknown, conditionValue: unknown, conditionType: ConditionType);
11
+ }
12
+ /**
13
+ * This error is thrown when a evaluation condition value is not valid
14
+ */
15
+ export declare class SafeRuleEvaluationConditionValueError extends BaseError {
16
+ /**
17
+ * This error is thrown when a evaluation condition value is not valid
18
+ */
19
+ constructor(dataValue: unknown, conditionValue: unknown, conditionType: ConditionType);
20
+ }
21
+ /**
22
+ * This error is thrown when a speical condition pattern is not valid
23
+ */
24
+ export declare class SafeRuleEvaluationSpecialConditionPatternError extends BaseError {
25
+ /**
26
+ * This error is thrown when a speical condition pattern is not valid
27
+ */
28
+ constructor(dataValue: unknown, conditionValue: unknown);
29
+ }
30
+ //# sourceMappingURL=safe-rules-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-rules-errors.d.ts","sourceRoot":"","sources":["../../../src/errors/safe/safe-rules-errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C;;GAEG;AACH,qBAAa,yCAA0C,SAAQ,SAAS;IACpE;;OAEG;gBACS,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa;CAGxF;AAED;;GAEG;AACH,qBAAa,qCAAsC,SAAQ,SAAS;IAChE;;OAEG;gBACS,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa;CAGxF;AAED;;GAEG;AACH,qBAAa,8CAA+C,SAAQ,SAAS;IACzE;;OAEG;gBACS,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO;CAG1D"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SafeRuleEvaluationSpecialConditionPatternError = exports.SafeRuleEvaluationConditionValueError = exports.SafeRuleEvaluationConditionDataValueError = void 0;
4
+ const base_error_1 = require("../base-error");
5
+ /**
6
+ * This error is thrown when a evaluation condition data value is not valid
7
+ */
8
+ class SafeRuleEvaluationConditionDataValueError extends base_error_1.BaseError {
9
+ /**
10
+ * This error is thrown when a evaluation condition data value is not valid
11
+ */
12
+ constructor(dataValue, conditionValue, conditionType) {
13
+ super(`Share Rule condition evaluation for type ${conditionType} failed to execute. dataValue: ${dataValue} is incorrect for conditionValue: ${conditionValue}`);
14
+ }
15
+ }
16
+ exports.SafeRuleEvaluationConditionDataValueError = SafeRuleEvaluationConditionDataValueError;
17
+ /**
18
+ * This error is thrown when a evaluation condition value is not valid
19
+ */
20
+ class SafeRuleEvaluationConditionValueError extends base_error_1.BaseError {
21
+ /**
22
+ * This error is thrown when a evaluation condition value is not valid
23
+ */
24
+ constructor(dataValue, conditionValue, conditionType) {
25
+ super(`Share Rule condition evaluation for type ${conditionType} failed to execute. conditionValue: ${conditionValue} is incorrect for dataValue: ${dataValue}`);
26
+ }
27
+ }
28
+ exports.SafeRuleEvaluationConditionValueError = SafeRuleEvaluationConditionValueError;
29
+ /**
30
+ * This error is thrown when a speical condition pattern is not valid
31
+ */
32
+ class SafeRuleEvaluationSpecialConditionPatternError extends base_error_1.BaseError {
33
+ /**
34
+ * This error is thrown when a speical condition pattern is not valid
35
+ */
36
+ constructor(dataValue, conditionValue) {
37
+ super(`Share Rule special condition pattern evaluation failed to execute. dataValue ${dataValue} and conditionValue: ${conditionValue}`);
38
+ }
39
+ }
40
+ exports.SafeRuleEvaluationSpecialConditionPatternError = SafeRuleEvaluationSpecialConditionPatternError;
@@ -1 +1,73 @@
1
+ import { IShareDataEvent } from '../models/events/share-event-models';
2
+ import { IShareRuleApplied, IShareRuleEvalutionResult } from '../models/rules/share-rule-models';
3
+ import { IShareFunction, IShareTransactionHistory, IShareData } from '../models/share-data/share-data';
4
+ /**
5
+ * This contains the interface for the share data object
6
+ */
7
+ export declare class ShareData {
8
+ private _id;
9
+ private _rules;
10
+ private _functions;
11
+ private _transactionHistory;
12
+ private _events;
13
+ private isLocked;
14
+ private _data;
15
+ /**
16
+ * This is the constructor for the share data object
17
+ * @param id the id of the share data
18
+ */
19
+ constructor(id: string);
20
+ /**
21
+ * This adds a rule to the share block.
22
+ * @param rule the rule to add to the share block
23
+ */
24
+ addRule(rule: IShareRuleApplied): void;
25
+ /**
26
+ * This gets the rules for the share block
27
+ */
28
+ get rules(): IShareRuleApplied[];
29
+ /**
30
+ * This gets the transaction history for the share block
31
+ */
32
+ addFunction(func: IShareFunction<any, (...args: any[]) => any, any>): void;
33
+ /**
34
+ * This gets the functions for the share block
35
+ */
36
+ get functions(): IShareFunction<any, (...args: any[]) => any, any>[];
37
+ /**
38
+ * This gets the events for the sharedata
39
+ */
40
+ get events(): IShareDataEvent[];
41
+ /**
42
+ * This adds an event to the share data
43
+ * @param event the event to add
44
+ */
45
+ addEvent(event: IShareDataEvent): void;
46
+ /**
47
+ * This adds a transaction to the share block
48
+ * @param rulesEvaluation the evaluation of the rules (result)
49
+ * @param transactionFunction the function that was run
50
+ */
51
+ addTransactionAlreadyValidated(proposedData: IShareData, rulesEvaluation: IShareRuleEvalutionResult, transactionFunction: IShareFunction<any, (...args: any[]) => any, any>): void;
52
+ /**
53
+ * This adds a transaction to the share block but the transaction has not yet been validated
54
+ *
55
+ * @param proposedData the proposed data
56
+ * @param transactionFunction the function that was attempted
57
+ */
58
+ addTransactionNotValidated(proposedData: IShareData, transactionFunction: IShareFunction<any, (...args: any[]) => any, any>): void;
59
+ /**
60
+ * This gets the transaction history for the share block
61
+ */
62
+ get transactionHistory(): IShareTransactionHistory[];
63
+ /**
64
+ * This returns the current state of data for the share block
65
+ */
66
+ get data(): IShareData;
67
+ /**
68
+ * This copies a share data object to a new transaction number
69
+ * @param transactionNumber the number of the transaction to run until.
70
+ */
71
+ copyTo(transactionNumber: number): ShareData;
72
+ }
1
73
  //# sourceMappingURL=share-data.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"share-data.d.ts","sourceRoot":"","sources":["../../src/share-data/share-data.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"share-data.d.ts","sourceRoot":"","sources":["../../src/share-data/share-data.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,UAAU,EAAkB,MAAM,iCAAiC,CAAC;AAEvH;;GAEG;AACH,qBAAa,SAAS;IAClB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,UAAU,CAAsD;IACxE,OAAO,CAAC,mBAAmB,CAA6B;IACxD,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,KAAK,CAAa;IAE1B;;;OAGG;gBACS,EAAE,EAAE,MAAM;IAYtB;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI;IAOtC;;OAEG;IACH,IAAI,KAAK,IAAI,iBAAiB,EAAE,CAE/B;IAED;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI;IAO1E;;OAEG;IACH,IAAI,SAAS,IAAI,cAAc,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,GAAG,CAAC,EAAE,CAEnE;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,eAAe,EAAE,CAE9B;IAED;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;IAItC;;;;OAIG;IACH,8BAA8B,CAC1B,YAAY,EAAE,UAAU,EACxB,eAAe,EAAE,yBAAyB,EAC1C,mBAAmB,EAAE,cAAc,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,GAAG,CAAC,GACvE,IAAI;IAwBP;;;;;OAKG;IACH,0BAA0B,CACtB,YAAY,EAAE,UAAU,EACxB,mBAAmB,EAAE,cAAc,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,GAAG,CAAC,GACvE,IAAI;IA0BP;;OAEG;IACH,IAAI,kBAAkB,IAAI,wBAAwB,EAAE,CAEnD;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,UAAU,CAErB;IAED;;;OAGG;IACH,MAAM,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS;CAW/C"}
@@ -1,166 +1,152 @@
1
1
  "use strict";
2
- // import { startRuleEvaluation } from '../../../rules/src/evaluation/start-rule-evaluation';
3
- // import { ShareDataIsLockedError } from '../errors';
4
- // import { IShareDataEvent } from '../models/events/share-event-models';
5
- // import { IShareRuleApplied, IShareRuleEvalutionResult } from '../models/rules/share-rule-models';
6
- // import { IShareFunction, IShareTransactionHistory, IShareData, ShareDataTypes } from '../models/share-data/share-data';
7
- // /**
8
- // * This contains the interface for the share data object
9
- // */
10
- // export class ShareData {
11
- // private _id: string; // the id of the share data
12
- // private _rules: IShareRuleApplied[]; // the rules for the share data
13
- // private _functions: IShareFunction<any, (...args: any[]) => any, any>[]; // the functions for the share data
14
- // private _transactionHistory: IShareTransactionHistory[]; // The transaction history for the share data
15
- // private _events: IShareDataEvent[]; // the events for the share data
16
- // private isLocked: boolean; // the lock status of the share data
17
- // private _data: IShareData; // the data for the share data
18
- // /**
19
- // * This is the constructor for the share data object
20
- // * @param id the id of the share data
21
- // */
22
- // constructor(id: string) {
23
- // this.isLocked = false;
24
- // this._id = id;
25
- // this._rules = [];
26
- // this._functions = [];
27
- // this._transactionHistory = [];
28
- // this._events = [];
29
- // this._data = {};
30
- // }
31
- // //#region Getters and Setters
32
- // /**
33
- // * This adds a rule to the share block.
34
- // * @param rule the rule to add to the share block
35
- // */
36
- // addRule(rule: IShareRuleApplied): void {
37
- // if (this.isLocked) {
38
- // throw new ShareDataIsLockedError(this._id, ShareDataTypes.RULE);
39
- // }
40
- // this._rules.push(rule);
41
- // }
42
- // /**
43
- // * This gets the rules for the share block
44
- // */
45
- // get rules(): IShareRuleApplied[] {
46
- // return this._rules;
47
- // }
48
- // /**
49
- // * This gets the transaction history for the share block
50
- // */
51
- // addFunction(func: IShareFunction<any, (...args: any[]) => any, any>): void {
52
- // if (this.isLocked) {
53
- // throw new ShareDataIsLockedError(this._id, ShareDataTypes.FUNCTION);
54
- // }
55
- // this._functions.push(func);
56
- // }
57
- // /**
58
- // * This gets the functions for the share block
59
- // */
60
- // get functions(): IShareFunction<any, (...args: any[]) => any, any>[] {
61
- // return this._functions;
62
- // }
63
- // /**
64
- // * This gets the events for the sharedata
65
- // */
66
- // get events(): IShareDataEvent[] {
67
- // return this._events;
68
- // }
69
- // /**
70
- // * This adds an event to the share data
71
- // * @param event the event to add
72
- // */
73
- // addEvent(event: IShareDataEvent): void {
74
- // this._events.push(event);
75
- // }
76
- // /**
77
- // * This adds a transaction to the share block
78
- // * @param rulesEvaluation the evaluation of the rules (result)
79
- // * @param transactionFunction the function that was run
80
- // */
81
- // addTransactionAlreadyValidated(
82
- // proposedData: IShareData,
83
- // rulesEvaluation: IShareRuleEvalutionResult,
84
- // transactionFunction: IShareFunction<any, (...args: any[]) => any, any>,
85
- // ): void {
86
- // // make sure the function is known.
87
- // if (!this._functions.includes(transactionFunction)) {
88
- // throw new Error('The function is not known');
89
- // }
90
- // const transactionTime = Date.now(); // get the current time
91
- // const transactionId = this._transactionHistory.length + 1; // get the transaction id
92
- // const ruleOutcome = (rulesEvaluation.proposedResult && rulesEvaluation.currentResult);
93
- // const transaction: IShareTransactionHistory = {
94
- // ruleOutcome,
95
- // ruleFailures: [],
96
- // transactionFunction,
97
- // transactionId: transactionId.toString(),
98
- // transactionTime,
99
- // };
100
- // // the outcome of the rules is valid write the data to be the new current data.
101
- // if (ruleOutcome) {
102
- // this._data = proposedData;
103
- // }
104
- // this._transactionHistory.push(transaction);
105
- // }
106
- // /**
107
- // * This adds a transaction to the share block but the transaction has not yet been validated
108
- // *
109
- // * @param proposedData the proposed data
110
- // * @param transactionFunction the function that was attempted
111
- // */
112
- // addTransactionNotValidated(
113
- // proposedData: IShareData,
114
- // transactionFunction: IShareFunction<any, (...args: any[]) => any, any>,
115
- // ): void {
116
- // // make sure the function is known.
117
- // if (!this._functions.includes(transactionFunction)) {
118
- // // throw ShareDataFunctionBeingAppliedDoesNotExistOnShareDataError
119
- // throw new Error('The function is not known');
120
- // }
121
- // // // evaluate the rules.
122
- // // const rulesEvalOutcome = evaluateRules('transaction', this._data, proposedData, this._rules);
123
- // const rulesOutcome = startRuleEvaluation(this._id, transactionFunction, this.functions, this._rules, this._data, proposedData);
124
- // const transactionTime = Date.now(); // get the current time
125
- // const transactionId = this._transactionHistory.length + 1; // get the transaction id
126
- // const transaction: IShareTransactionHistory = {
127
- // ruleOutcome: rulesOutcome.isValidProposal,
128
- // ruleFailures: [],
129
- // transactionFunction,
130
- // transactionId: transactionId.toString(),
131
- // transactionTime,
132
- // };
133
- // // update the data if the rules are valid
134
- // if (rulesOutcome.isValidProposal) {
135
- // this._data = proposedData;
136
- // }
137
- // // add the transaction to the history
138
- // this._transactionHistory.push(transaction);
139
- // }
140
- // /**
141
- // * This gets the transaction history for the share block
142
- // */
143
- // get transactionHistory(): IShareTransactionHistory[] {
144
- // return this._transactionHistory;
145
- // }
146
- // /**
147
- // * This returns the current state of data for the share block
148
- // */
149
- // get data(): IShareData {
150
- // return this._data;
151
- // }
152
- // /**
153
- // * This copies a share data object to a new transaction number
154
- // * @param transactionNumber the number of the transaction to run until.
155
- // */
156
- // copyTo(transactionNumber: number): ShareData {
157
- // // return share data with a new ID
158
- // const newShareData = new ShareData(`${this._id}-${transactionNumber}`);
159
- // newShareData._rules = [...this._rules];
160
- // newShareData._functions = [...this._functions];
161
- // newShareData._transactionHistory = [...this._transactionHistory];
162
- // newShareData._data = { ...this._data };
163
- // return newShareData;
164
- // }
165
- // //#endregion Getters and Setters
166
- // }
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ShareData = void 0;
4
+ const rules_1 = require("@degenerate/rules");
5
+ const errors_1 = require("../errors");
6
+ const share_data_1 = require("../models/share-data/share-data");
7
+ /**
8
+ * This contains the interface for the share data object
9
+ */
10
+ class ShareData {
11
+ /**
12
+ * This is the constructor for the share data object
13
+ * @param id the id of the share data
14
+ */
15
+ constructor(id) {
16
+ this.isLocked = false;
17
+ this._id = id;
18
+ this._rules = [];
19
+ this._functions = [];
20
+ this._transactionHistory = [];
21
+ this._events = [];
22
+ this._data = {};
23
+ }
24
+ //#region Getters and Setters
25
+ /**
26
+ * This adds a rule to the share block.
27
+ * @param rule the rule to add to the share block
28
+ */
29
+ addRule(rule) {
30
+ if (this.isLocked) {
31
+ throw new errors_1.ShareDataIsLockedError(this._id, share_data_1.ShareDataTypes.RULE);
32
+ }
33
+ this._rules.push(rule);
34
+ }
35
+ /**
36
+ * This gets the rules for the share block
37
+ */
38
+ get rules() {
39
+ return this._rules;
40
+ }
41
+ /**
42
+ * This gets the transaction history for the share block
43
+ */
44
+ addFunction(func) {
45
+ if (this.isLocked) {
46
+ throw new errors_1.ShareDataIsLockedError(this._id, share_data_1.ShareDataTypes.FUNCTION);
47
+ }
48
+ this._functions.push(func);
49
+ }
50
+ /**
51
+ * This gets the functions for the share block
52
+ */
53
+ get functions() {
54
+ return this._functions;
55
+ }
56
+ /**
57
+ * This gets the events for the sharedata
58
+ */
59
+ get events() {
60
+ return this._events;
61
+ }
62
+ /**
63
+ * This adds an event to the share data
64
+ * @param event the event to add
65
+ */
66
+ addEvent(event) {
67
+ this._events.push(event);
68
+ }
69
+ /**
70
+ * This adds a transaction to the share block
71
+ * @param rulesEvaluation the evaluation of the rules (result)
72
+ * @param transactionFunction the function that was run
73
+ */
74
+ addTransactionAlreadyValidated(proposedData, rulesEvaluation, transactionFunction) {
75
+ // make sure the function is known.
76
+ if (!this._functions.includes(transactionFunction)) {
77
+ throw new Error('The function is not known');
78
+ }
79
+ const transactionTime = Date.now(); // get the current time
80
+ const transactionId = this._transactionHistory.length + 1; // get the transaction id
81
+ const ruleOutcome = (rulesEvaluation.proposedResult && rulesEvaluation.currentResult);
82
+ const transaction = {
83
+ ruleOutcome,
84
+ ruleFailures: [],
85
+ transactionFunction,
86
+ transactionId: transactionId.toString(),
87
+ transactionTime,
88
+ };
89
+ // the outcome of the rules is valid write the data to be the new current data.
90
+ if (ruleOutcome) {
91
+ this._data = proposedData;
92
+ }
93
+ this._transactionHistory.push(transaction);
94
+ }
95
+ /**
96
+ * This adds a transaction to the share block but the transaction has not yet been validated
97
+ *
98
+ * @param proposedData the proposed data
99
+ * @param transactionFunction the function that was attempted
100
+ */
101
+ addTransactionNotValidated(proposedData, transactionFunction) {
102
+ // make sure the function is known.
103
+ if (!this._functions.includes(transactionFunction)) {
104
+ // throw ShareDataFunctionBeingAppliedDoesNotExistOnShareDataError
105
+ throw new Error('The function is not known');
106
+ }
107
+ // // evaluate the rules.
108
+ // const rulesEvalOutcome = evaluateRules('transaction', this._data, proposedData, this._rules);
109
+ const rulesOutcome = (0, rules_1.startRuleEvaluation)(this._id, transactionFunction, this.functions, this._rules, this._data, proposedData);
110
+ const transactionTime = Date.now(); // get the current time
111
+ const transactionId = this._transactionHistory.length + 1; // get the transaction id
112
+ const transaction = {
113
+ ruleOutcome: rulesOutcome.isValidProposal,
114
+ ruleFailures: [],
115
+ transactionFunction,
116
+ transactionId: transactionId.toString(),
117
+ transactionTime,
118
+ };
119
+ // update the data if the rules are valid
120
+ if (rulesOutcome.isValidProposal) {
121
+ this._data = proposedData;
122
+ }
123
+ // add the transaction to the history
124
+ this._transactionHistory.push(transaction);
125
+ }
126
+ /**
127
+ * This gets the transaction history for the share block
128
+ */
129
+ get transactionHistory() {
130
+ return this._transactionHistory;
131
+ }
132
+ /**
133
+ * This returns the current state of data for the share block
134
+ */
135
+ get data() {
136
+ return this._data;
137
+ }
138
+ /**
139
+ * This copies a share data object to a new transaction number
140
+ * @param transactionNumber the number of the transaction to run until.
141
+ */
142
+ copyTo(transactionNumber) {
143
+ // return share data with a new ID
144
+ const newShareData = new ShareData(`${this._id}-${transactionNumber}`);
145
+ newShareData._rules = [...this._rules];
146
+ newShareData._functions = [...this._functions];
147
+ newShareData._transactionHistory = [...this._transactionHistory];
148
+ newShareData._data = { ...this._data };
149
+ return newShareData;
150
+ }
151
+ }
152
+ exports.ShareData = ShareData;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@degenerate/generic",
3
- "version": "0.0.10",
4
- "description": "This contains the generic information needed for the Distributed Execution Infrastructure network.",
3
+ "version": "0.0.13",
4
+ "description": "This contains the generic information needed for the ShareData Adaptive Framework Ecosystem (SAFE) network",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
@@ -48,6 +48,7 @@
48
48
  "typescript-eslint": "^8.9.0"
49
49
  },
50
50
  "dependencies": {
51
+ "@degenerate/rules": "^0.0.5",
51
52
  "bip39": "^3.1.0",
52
53
  "elliptic": "^6.5.7"
53
54
  }