@jd-data-limited/easy-fm 4.1.10 → 4.1.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.
@@ -22,9 +22,13 @@ export declare class Field<T extends FieldValue> {
22
22
  parent: Parentable;
23
23
  id: string;
24
24
  protected _value: T | null;
25
- edited: boolean;
26
25
  static firstContainerDownload: Promise<any> | null;
27
- constructor(record: Parentable, id: string, contents: T);
26
+ constructor(record: Parentable, id: string, originalContents: T);
27
+ get edited(): boolean;
28
+ /**
29
+ * Resets the 'edited' state of this field, without changing its value
30
+ */
31
+ updateOriginalContents(): void;
28
32
  /**
29
33
  * Sets the value of the field.
30
34
  *
@@ -70,13 +70,22 @@ let Field = (() => {
70
70
  parent = __runInitializers(this, _instanceExtraInitializers);
71
71
  id;
72
72
  _value;
73
- edited;
73
+ #originalContents;
74
74
  static firstContainerDownload = null;
75
- constructor(record, id, contents) {
75
+ constructor(record, id, originalContents) {
76
76
  this.parent = record;
77
77
  this.id = id;
78
- this._value = contents;
79
- this.edited = false;
78
+ this._value = originalContents;
79
+ this.#originalContents = originalContents;
80
+ }
81
+ get edited() {
82
+ return this.#originalContents !== this._value;
83
+ }
84
+ /**
85
+ * Resets the 'edited' state of this field, without changing its value
86
+ */
87
+ updateOriginalContents() {
88
+ this.#originalContents = this._value;
80
89
  }
81
90
  /**
82
91
  * Sets the value of the field.
@@ -89,7 +98,6 @@ let Field = (() => {
89
98
  throw new Error('Cannot set container value using set(). Use upload() instead.');
90
99
  else
91
100
  this._value = content;
92
- this.edited = true;
93
101
  }
94
102
  get metadata() {
95
103
  if (!this.parent.layout.metadata) {
@@ -154,7 +162,7 @@ let Field = (() => {
154
162
  return this._value;
155
163
  }
156
164
  set value(value) {
157
- this._value = value;
165
+ this.set(value);
158
166
  }
159
167
  get string() {
160
168
  if (typeof this._value === 'string') {
@@ -49,7 +49,7 @@ export class RecordBase extends EventEmitter {
49
49
  .utcOffset(this.layout.database.host.timezoneOffsetFunc(date), true)
50
50
  .local();
51
51
  _field.set(date);
52
- _field.edited = false;
52
+ _field.updateOriginalContents();
53
53
  }
54
54
  else if (_field.metadata.result === 'time') {
55
55
  let date = moment.default(fieldData[key]);
@@ -57,7 +57,7 @@ export class RecordBase extends EventEmitter {
57
57
  .utcOffset(this.layout.database.host.timezoneOffsetFunc(date), true)
58
58
  .local();
59
59
  _field.set(date);
60
- _field.edited = false;
60
+ _field.updateOriginalContents();
61
61
  }
62
62
  else if (_field.metadata.result === 'date') {
63
63
  let date = moment.default(fieldData[key]);
@@ -65,7 +65,7 @@ export class RecordBase extends EventEmitter {
65
65
  .utcOffset(this.layout.database.host.timezoneOffsetFunc(date), true)
66
66
  .local();
67
67
  _field.set(date);
68
- _field.edited = false;
68
+ _field.updateOriginalContents();
69
69
  }
70
70
  }
71
71
  fields[key] = _field;
@@ -76,6 +76,6 @@ export class RecordBase extends EventEmitter {
76
76
  _onSave() {
77
77
  this.emit('saved');
78
78
  for (const field of this.fieldsArray)
79
- field.edited = false;
79
+ field.updateOriginalContents();
80
80
  }
81
81
  }
package/dist/types.d.ts CHANGED
@@ -55,14 +55,14 @@ export interface extraBodyOptions {
55
55
  * user (default) - Field validation occurs as per normal. Request is blocked if validation failed.
56
56
  * script - Field validation is overridden/ignored when allowed in the database schema.
57
57
  */
58
- entrymode: 'user' | 'script';
58
+ entrymode?: 'user' | 'script';
59
59
  /**
60
60
  * Overrides the 'prohibit modification of this field during data entry' property (FileMaker Server 2024 - 21.1.1 and newer)
61
61
  * user (default) - Follow this rule
62
62
  * script - Ignore this rule
63
63
  */
64
- prohibitMode: 'user' | 'script';
65
- };
64
+ prohibitmode?: 'user' | 'script';
65
+ } & Record<string, any>;
66
66
  deleteRelatedRecords?: Array<{
67
67
  table: string;
68
68
  recordId: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jd-data-limited/easy-fm",
3
- "version": "4.1.10",
3
+ "version": "4.1.13",
4
4
  "dependencies": {
5
5
  "@types/follow-redirects": "^1.14.4",
6
6
  "@types/node": "^22.7.7",