pict-section-recordset 1.24.0 → 1.24.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pict-section-recordset",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.1",
|
|
4
4
|
"description": "Pict dynamic record set management views",
|
|
5
5
|
"main": "source/Pict-Section-RecordSet.js",
|
|
6
6
|
"files": [
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"browser-env": "^3.3.0",
|
|
38
38
|
"eslint": "^9.28.0",
|
|
39
39
|
"jquery": "^3.7.1",
|
|
40
|
-
"pict": "^1.0.
|
|
40
|
+
"pict": "^1.0.390",
|
|
41
41
|
"pict-application": "^1.0.34",
|
|
42
42
|
"pict-docuserve": "^1.4.19",
|
|
43
|
-
"pict-service-commandlineutility": "^1.0.
|
|
43
|
+
"pict-service-commandlineutility": "^1.0.20",
|
|
44
44
|
"quackage": "^1.3.0",
|
|
45
45
|
"typescript": "^5.9.3"
|
|
46
46
|
},
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"fable-serviceproviderbase": "^3.0.19",
|
|
49
49
|
"pict-provider": "^1.0.13",
|
|
50
50
|
"pict-router": "^1.0.10",
|
|
51
|
-
"pict-section-form": "^1.
|
|
51
|
+
"pict-section-form": "^1.3.2",
|
|
52
52
|
"pict-template": "^1.0.15",
|
|
53
53
|
"pict-view": "^1.0.68",
|
|
54
54
|
"sinon": "^21.0.1"
|
|
@@ -101,7 +101,8 @@ class MeadowEndpointsRecordSetProvider extends libRecordSetProviderBase
|
|
|
101
101
|
return tmpCallback(new Error('RecordSet provider cannot resolve a distinct request (missing Entity or rest client).'), []);
|
|
102
102
|
}
|
|
103
103
|
const tmpURL = `${this.options.URLPrefix || ''}${this.options.Entity}s/Distinct/${pColumn}${tmpOptions.Filter ? `/FilteredTo/${tmpOptions.Filter}` : ''}`;
|
|
104
|
-
this.entityProvider
|
|
104
|
+
const tmpEntityProvider = this.entityProvider;
|
|
105
|
+
const fHandleDistinctResult = (pError, pResponse, pBody) =>
|
|
105
106
|
{
|
|
106
107
|
if (pError || (pResponse && pResponse.statusCode > 299) || !Array.isArray(pBody))
|
|
107
108
|
{
|
|
@@ -112,6 +113,37 @@ class MeadowEndpointsRecordSetProvider extends libRecordSetProviderBase
|
|
|
112
113
|
const tmpValues = [ ...new Set(pBody.map((pRecord) => pRecord && pRecord[pColumn]).filter((pValue) => pValue != null)) ];
|
|
113
114
|
this._scopeDistinctCache[tmpCacheKey] = tmpValues;
|
|
114
115
|
return tmpCallback(null, tmpValues);
|
|
116
|
+
};
|
|
117
|
+
// Route through POST /:Entity/Query (Distinct mode) when the endpoint
|
|
118
|
+
// supports it — a long /FilteredTo/ stanza on the Distinct GET is the same
|
|
119
|
+
// URI-length hazard the Query route exists to sidestep. Falls back to GET.
|
|
120
|
+
const fResolveSupport = (typeof tmpEntityProvider.resolveEntityQuerySupport === 'function')
|
|
121
|
+
? tmpEntityProvider.resolveEntityQuerySupport.bind(tmpEntityProvider)
|
|
122
|
+
: (pEntity, pPrefix, fCb) => { return fCb(null, false); };
|
|
123
|
+
fResolveSupport(this.options.Entity, this.options.URLPrefix, (pSupportError, pSupportsQuery) =>
|
|
124
|
+
{
|
|
125
|
+
if (pSupportsQuery)
|
|
126
|
+
{
|
|
127
|
+
const tmpBody = { Distinct: true, Columns: pColumn };
|
|
128
|
+
if (tmpOptions.Filter)
|
|
129
|
+
{
|
|
130
|
+
// The Filter is URL-encoded by contract — it is interpolated verbatim into the
|
|
131
|
+
// GET /FilteredTo/ path segment, which the server URL-decodes. A JSON body is not
|
|
132
|
+
// URL-decoded, so decode it here to keep the POST semantics identical to the GET.
|
|
133
|
+
let tmpFilter = tmpOptions.Filter;
|
|
134
|
+
try
|
|
135
|
+
{
|
|
136
|
+
tmpFilter = decodeURIComponent(tmpOptions.Filter);
|
|
137
|
+
}
|
|
138
|
+
catch (pDecodeError)
|
|
139
|
+
{
|
|
140
|
+
this.pict.log.warn(`RecordSet [${this.options.RecordSet || this.options.Entity}] could not URL-decode the distinct filter for the Query body; sending it verbatim.`, { Error: pDecodeError && pDecodeError.message, Filter: tmpOptions.Filter });
|
|
141
|
+
}
|
|
142
|
+
tmpBody.Filter = tmpFilter;
|
|
143
|
+
}
|
|
144
|
+
return tmpEntityProvider.restClient.postJSON({ url: `${this.options.URLPrefix || ''}${this.options.Entity}s/Query`, body: tmpBody }, fHandleDistinctResult);
|
|
145
|
+
}
|
|
146
|
+
return tmpEntityProvider.restClient.getJSON(tmpURL, fHandleDistinctResult);
|
|
115
147
|
});
|
|
116
148
|
}
|
|
117
149
|
|
|
@@ -1006,6 +1038,13 @@ class MeadowEndpointsRecordSetProvider extends libRecordSetProviderBase
|
|
|
1006
1038
|
return fCallback(error);
|
|
1007
1039
|
}
|
|
1008
1040
|
this._Schema = result;
|
|
1041
|
+
// The schema response carries the endpoint's version/capability
|
|
1042
|
+
// metadata; seed the entity provider's capability cache from it so
|
|
1043
|
+
// reads avoid a redundant capability probe.
|
|
1044
|
+
if (this.entityProvider && typeof this.entityProvider.primeEntityCapabilityFromSchema === 'function')
|
|
1045
|
+
{
|
|
1046
|
+
this.entityProvider.primeEntityCapabilityFromSchema(this.options.Entity, result, this.options.URLPrefix);
|
|
1047
|
+
}
|
|
1009
1048
|
return fCallback(null);
|
|
1010
1049
|
});
|
|
1011
1050
|
}).catch((error) =>
|