@salesforce/lds-runtime-mobile 1.103.0 → 1.104.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/dist/main.js +147 -105
- package/package.json +15 -15
- package/sfdc/main.js +147 -105
package/dist/main.js
CHANGED
|
@@ -4353,33 +4353,58 @@ function makeStoreEval(preconditioner, objectInfoService, userId, contextProvide
|
|
|
4353
4353
|
class AsyncWorkerPool {
|
|
4354
4354
|
constructor(concurrency) {
|
|
4355
4355
|
this.queue = [];
|
|
4356
|
-
this.
|
|
4356
|
+
this.activeWork = [];
|
|
4357
4357
|
this.concurrency = concurrency;
|
|
4358
4358
|
}
|
|
4359
|
-
push(
|
|
4359
|
+
push(work) {
|
|
4360
4360
|
return new Promise((resolve, reject) => {
|
|
4361
|
-
this.queue.push(
|
|
4362
|
-
|
|
4361
|
+
this.queue.push({
|
|
4362
|
+
...work,
|
|
4363
|
+
workFn: () => work.workFn().then(resolve).catch(reject),
|
|
4363
4364
|
});
|
|
4364
|
-
this.
|
|
4365
|
+
this.doWork();
|
|
4365
4366
|
});
|
|
4366
4367
|
}
|
|
4367
|
-
cancel() {
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
const
|
|
4375
|
-
if (
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4368
|
+
async cancel() {
|
|
4369
|
+
const promises = [];
|
|
4370
|
+
const cancellingWork = [
|
|
4371
|
+
...this.activeWork.splice(0, this.activeWork.length),
|
|
4372
|
+
...this.queue.splice(0, this.queue.length),
|
|
4373
|
+
];
|
|
4374
|
+
cancellingWork.forEach((work) => {
|
|
4375
|
+
const { cancelFn } = work;
|
|
4376
|
+
if (cancelFn) {
|
|
4377
|
+
promises.push(cancelFn());
|
|
4378
|
+
}
|
|
4379
|
+
});
|
|
4380
|
+
await promiseAllSettled(promises);
|
|
4381
|
+
}
|
|
4382
|
+
doWork() {
|
|
4383
|
+
while (this.queue.length > 0 && this.activeWork.length < this.concurrency) {
|
|
4384
|
+
const work = this.queue.shift();
|
|
4385
|
+
if (work) {
|
|
4386
|
+
this.activeWork.push(work);
|
|
4387
|
+
const { workFn } = work;
|
|
4388
|
+
workFn()
|
|
4389
|
+
.then()
|
|
4390
|
+
.finally(() => {
|
|
4391
|
+
this.activeWork = this.activeWork.filter((w) => w !== work);
|
|
4392
|
+
this.doWork();
|
|
4379
4393
|
});
|
|
4380
4394
|
}
|
|
4381
4395
|
}
|
|
4382
4396
|
}
|
|
4397
|
+
}
|
|
4398
|
+
function promiseAllSettled(promises) {
|
|
4399
|
+
return Promise.all(promises.map((promise) => promise
|
|
4400
|
+
.then((value) => ({
|
|
4401
|
+
status: 'fulfilled',
|
|
4402
|
+
value,
|
|
4403
|
+
}))
|
|
4404
|
+
.catch((reason) => ({
|
|
4405
|
+
status: 'rejected',
|
|
4406
|
+
reason,
|
|
4407
|
+
}))));
|
|
4383
4408
|
}
|
|
4384
4409
|
|
|
4385
4410
|
/**
|
|
@@ -4895,25 +4920,27 @@ class DurableDraftQueue {
|
|
|
4895
4920
|
});
|
|
4896
4921
|
}
|
|
4897
4922
|
async enqueue(handlerId, data) {
|
|
4898
|
-
return this.workerPool.push(
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
this.
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4923
|
+
return this.workerPool.push({
|
|
4924
|
+
workFn: async () => {
|
|
4925
|
+
let queue = await this.getQueueActions();
|
|
4926
|
+
const handler = this.getHandler(handlerId);
|
|
4927
|
+
const pendingAction = (await handler.buildPendingAction(data, queue));
|
|
4928
|
+
await this.draftStore.writeAction(pendingAction);
|
|
4929
|
+
queue = await this.getQueueActions();
|
|
4930
|
+
await this.notifyChangedListeners({
|
|
4931
|
+
type: DraftQueueEventType.ActionAdded,
|
|
4932
|
+
action: pendingAction,
|
|
4933
|
+
});
|
|
4934
|
+
await handler.handleActionEnqueued(pendingAction, queue);
|
|
4935
|
+
if (this.state === DraftQueueState.Started) {
|
|
4936
|
+
this.processNextAction();
|
|
4937
|
+
}
|
|
4938
|
+
const actionData = (await handler.getDataForAction(pendingAction));
|
|
4939
|
+
return {
|
|
4940
|
+
action: pendingAction,
|
|
4941
|
+
data: actionData,
|
|
4942
|
+
};
|
|
4943
|
+
},
|
|
4917
4944
|
});
|
|
4918
4945
|
}
|
|
4919
4946
|
registerOnChangedListener(listener) {
|
|
@@ -4926,28 +4953,30 @@ class DurableDraftQueue {
|
|
|
4926
4953
|
};
|
|
4927
4954
|
}
|
|
4928
4955
|
async actionCompleted(action) {
|
|
4929
|
-
return this.workerPool.push(
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4956
|
+
return this.workerPool.push({
|
|
4957
|
+
workFn: async () => {
|
|
4958
|
+
const handler = this.getHandler(action.handler);
|
|
4959
|
+
let queue = await this.getQueueActions();
|
|
4960
|
+
const queueOperations = handler.getQueueOperationsForCompletingDrafts(queue, action);
|
|
4961
|
+
const idAndKeyMappings = handler.getRedirectMappings(action);
|
|
4962
|
+
const keyMappings = idAndKeyMappings === undefined
|
|
4963
|
+
? undefined
|
|
4964
|
+
: idAndKeyMappings.map((m) => {
|
|
4965
|
+
return { draftKey: m.draftKey, canonicalKey: m.canonicalKey };
|
|
4966
|
+
});
|
|
4967
|
+
await this.draftStore.completeAction(queueOperations, keyMappings);
|
|
4968
|
+
queue = await this.getQueueActions();
|
|
4969
|
+
this.retryIntervalMilliseconds = 0;
|
|
4970
|
+
this.uploadingActionId = undefined;
|
|
4971
|
+
await handler.handleActionCompleted(action, queueOperations, queue, values$1(this.handlers));
|
|
4972
|
+
await this.notifyChangedListeners({
|
|
4973
|
+
type: DraftQueueEventType.ActionCompleted,
|
|
4974
|
+
action,
|
|
4938
4975
|
});
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
await handler.handleActionCompleted(action, queueOperations, queue, values$1(this.handlers));
|
|
4944
|
-
await this.notifyChangedListeners({
|
|
4945
|
-
type: DraftQueueEventType.ActionCompleted,
|
|
4946
|
-
action,
|
|
4947
|
-
});
|
|
4948
|
-
if (this.state === DraftQueueState.Started) {
|
|
4949
|
-
this.processNextAction();
|
|
4950
|
-
}
|
|
4976
|
+
if (this.state === DraftQueueState.Started) {
|
|
4977
|
+
this.processNextAction();
|
|
4978
|
+
}
|
|
4979
|
+
},
|
|
4951
4980
|
});
|
|
4952
4981
|
}
|
|
4953
4982
|
async actionFailed(action, retry) {
|
|
@@ -9082,7 +9111,9 @@ async function injectSyntheticFields(originalAST, objectInfoService, draftFuncti
|
|
|
9082
9111
|
if (node.name.value === 'where') {
|
|
9083
9112
|
const ancestorPath = findAncesterPath(ancestors);
|
|
9084
9113
|
if (idState.paths.includes(ancestorPath)) {
|
|
9085
|
-
const
|
|
9114
|
+
const apiName = objectInfoApiMap[ancestorPath][0];
|
|
9115
|
+
const objectInfo = objectInfos[apiName];
|
|
9116
|
+
const swappedIdFilter = swapIdField(node.value, objectInfo, false, idState, draftFunctions);
|
|
9086
9117
|
return {
|
|
9087
9118
|
...node,
|
|
9088
9119
|
value: swappedIdFilter,
|
|
@@ -9094,20 +9125,20 @@ async function injectSyntheticFields(originalAST, objectInfoService, draftFuncti
|
|
|
9094
9125
|
});
|
|
9095
9126
|
return { modifiedAST, objectInfos, unmappedDraftIDs: idState.unmappedDraftIDs };
|
|
9096
9127
|
}
|
|
9097
|
-
function swapIdField(filterFields, swapped, idState, draftFunctions) {
|
|
9128
|
+
function swapIdField(filterFields, objectInfo, swapped, idState, draftFunctions) {
|
|
9098
9129
|
switch (filterFields.kind) {
|
|
9099
9130
|
case Kind.OBJECT: {
|
|
9100
9131
|
const fieldNodes = [];
|
|
9101
9132
|
for (const fieldNode of filterFields.fields) {
|
|
9102
9133
|
if (isObjectValueNode(fieldNode.value)) {
|
|
9103
|
-
const fieldValue = swapIdField(fieldNode.value, fieldNode.name.value
|
|
9134
|
+
const fieldValue = swapIdField(fieldNode.value, objectInfo, isFieldAnIdField(fieldNode.name.value, objectInfo), idState, draftFunctions);
|
|
9104
9135
|
fieldNodes.push({
|
|
9105
9136
|
...fieldNode,
|
|
9106
9137
|
value: fieldValue,
|
|
9107
9138
|
});
|
|
9108
9139
|
}
|
|
9109
9140
|
else {
|
|
9110
|
-
const fieldValue = swapIdField(fieldNode.value, swapped, idState, draftFunctions);
|
|
9141
|
+
const fieldValue = swapIdField(fieldNode.value, objectInfo, swapped, idState, draftFunctions);
|
|
9111
9142
|
fieldNodes.push({
|
|
9112
9143
|
...fieldNode,
|
|
9113
9144
|
value: fieldValue,
|
|
@@ -9654,13 +9685,16 @@ function injectFilter(filterNode, idState, path, objectInfos, objectInfoApiMap,
|
|
|
9654
9685
|
throw new Error(`Field ${fieldName} does not exist in ${apiNames[0]}`);
|
|
9655
9686
|
}
|
|
9656
9687
|
}
|
|
9657
|
-
const
|
|
9688
|
+
const objectInfoName = objectInfoApiMap[curPath] !== undefined
|
|
9689
|
+
? objectInfoApiMap[curPath][0]
|
|
9690
|
+
: objectInfoApiMap[path][0];
|
|
9691
|
+
const isIdField = isFieldAnIdField(filterNode.name.value, objectInfos[objectInfoName]);
|
|
9658
9692
|
if (!isIdField) {
|
|
9659
9693
|
let subSelectionNodes = [];
|
|
9660
9694
|
let subFieldsHasId = false;
|
|
9661
9695
|
filterNode.value.fields.forEach((subFieldNode) => {
|
|
9662
9696
|
// Check if the filter field has the 'Id'
|
|
9663
|
-
if (subFieldNode.name.value
|
|
9697
|
+
if (isFieldAnIdField(subFieldNode.name.value, objectInfos[objectInfoName])) {
|
|
9664
9698
|
subFieldsHasId = true;
|
|
9665
9699
|
updateIDInfo(subFieldNode, idState, draftFunctions);
|
|
9666
9700
|
}
|
|
@@ -9826,6 +9860,12 @@ function mergeOrAddToGroup(group, element) {
|
|
|
9826
9860
|
}
|
|
9827
9861
|
group.push(element);
|
|
9828
9862
|
}
|
|
9863
|
+
function isFieldAnIdField(fieldName, objectInfo) {
|
|
9864
|
+
if (fieldName === 'Id')
|
|
9865
|
+
return true;
|
|
9866
|
+
const field = objectInfo.fields[fieldName];
|
|
9867
|
+
return field !== undefined ? field.dataType === 'Reference' : false;
|
|
9868
|
+
}
|
|
9829
9869
|
// produces a 'value' FieldNode if input query node does not contains the 'value' subnode
|
|
9830
9870
|
function produceValueFieldLeaves(queryNode) {
|
|
9831
9871
|
const existingValueFields = queryNode &&
|
|
@@ -9846,14 +9886,12 @@ function produceValueFieldLeaves(queryNode) {
|
|
|
9846
9886
|
: [];
|
|
9847
9887
|
}
|
|
9848
9888
|
function updateIDInfo(fieldNode, idState, draftFunctions) {
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
idState.swapNeeded = draftFunctions.isDraftId(id);
|
|
9856
|
-
}
|
|
9889
|
+
idState.swapNeeded = true;
|
|
9890
|
+
if (isObjectValueNode(fieldNode.value)) {
|
|
9891
|
+
const idOpValueNode = fieldNode.value.fields[0];
|
|
9892
|
+
if (isStringValueNode(idOpValueNode.value)) {
|
|
9893
|
+
const id = idOpValueNode.value.value;
|
|
9894
|
+
idState.swapNeeded = draftFunctions.isDraftId(id);
|
|
9857
9895
|
}
|
|
9858
9896
|
}
|
|
9859
9897
|
}
|
|
@@ -14854,44 +14892,48 @@ class PrimingSession extends EventEmitter {
|
|
|
14854
14892
|
// parallelizes batches of priming work
|
|
14855
14893
|
enqueueBatches(batches) {
|
|
14856
14894
|
for (const batch of batches) {
|
|
14857
|
-
this.networkWorkerPool.push(
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
|
|
14861
|
-
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
|
|
14865
|
-
|
|
14866
|
-
|
|
14867
|
-
|
|
14868
|
-
|
|
14869
|
-
const { missingIds } = result;
|
|
14870
|
-
if (missingIds.length > 0) {
|
|
14871
|
-
this.emit('error', {
|
|
14872
|
-
ids: missingIds,
|
|
14873
|
-
code: 'not-found',
|
|
14874
|
-
message: `could not find records: ${missingIds.join(', ')}`,
|
|
14875
|
-
});
|
|
14876
|
-
}
|
|
14877
|
-
const { records } = result;
|
|
14878
|
-
// dispatch the write but DO NOT wait on it to unblock the network pool
|
|
14879
|
-
this.recordIngestor.insertRecords(records).then(({ written, conflicted }) => {
|
|
14880
|
-
// now that the records are persisted, emit the primed event
|
|
14881
|
-
if (written.length > 0) {
|
|
14882
|
-
this.emit('primed', Array.from(written));
|
|
14895
|
+
this.networkWorkerPool.push({
|
|
14896
|
+
workFn: () => {
|
|
14897
|
+
return this.recordLoader.fetchRecordData(batch).then(async (result) => {
|
|
14898
|
+
if (result.ok === false) {
|
|
14899
|
+
const { error } = result;
|
|
14900
|
+
const primingError = error === 'network-error' ? 'service-unavailable' : 'unknown';
|
|
14901
|
+
this.emit('error', {
|
|
14902
|
+
ids: result.missingIds,
|
|
14903
|
+
code: primingError,
|
|
14904
|
+
message: `${result.messages.join(',')}`,
|
|
14905
|
+
});
|
|
14906
|
+
return;
|
|
14883
14907
|
}
|
|
14884
|
-
|
|
14885
|
-
if (
|
|
14886
|
-
// for now emit conlicts as errors
|
|
14908
|
+
const { missingIds } = result;
|
|
14909
|
+
if (missingIds.length > 0) {
|
|
14887
14910
|
this.emit('error', {
|
|
14888
|
-
ids:
|
|
14889
|
-
code: '
|
|
14890
|
-
message:
|
|
14911
|
+
ids: missingIds,
|
|
14912
|
+
code: 'not-found',
|
|
14913
|
+
message: `could not find records: ${missingIds.join(', ')}`,
|
|
14891
14914
|
});
|
|
14892
14915
|
}
|
|
14916
|
+
const { records } = result;
|
|
14917
|
+
// dispatch the write but DO NOT wait on it to unblock the network pool
|
|
14918
|
+
this.recordIngestor
|
|
14919
|
+
.insertRecords(records)
|
|
14920
|
+
.then(({ written, conflicted }) => {
|
|
14921
|
+
// now that the records are persisted, emit the primed event
|
|
14922
|
+
if (written.length > 0) {
|
|
14923
|
+
this.emit('primed', Array.from(written));
|
|
14924
|
+
}
|
|
14925
|
+
// TODO [W-12436213]: implement conflict resolution
|
|
14926
|
+
if (conflicted.length > 0) {
|
|
14927
|
+
// for now emit conlicts as errors
|
|
14928
|
+
this.emit('error', {
|
|
14929
|
+
ids: Array.from(conflicted),
|
|
14930
|
+
code: 'unknown',
|
|
14931
|
+
message: 'conflict when persisting record',
|
|
14932
|
+
});
|
|
14933
|
+
}
|
|
14934
|
+
});
|
|
14893
14935
|
});
|
|
14894
|
-
}
|
|
14936
|
+
},
|
|
14895
14937
|
});
|
|
14896
14938
|
}
|
|
14897
14939
|
}
|
|
@@ -15281,4 +15323,4 @@ register({
|
|
|
15281
15323
|
});
|
|
15282
15324
|
|
|
15283
15325
|
export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
|
|
15284
|
-
// version: 1.
|
|
15326
|
+
// version: 1.104.1-1e6c5b3e6
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-runtime-mobile",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.104.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"description": "LDS runtime for mobile/hybrid environments.",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-mobile"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@salesforce/lds-adapters-uiapi": "^1.
|
|
36
|
-
"@salesforce/lds-bindings": "^1.
|
|
37
|
-
"@salesforce/lds-instrumentation": "^1.
|
|
38
|
-
"@salesforce/lds-priming": "^1.
|
|
35
|
+
"@salesforce/lds-adapters-uiapi": "^1.104.1",
|
|
36
|
+
"@salesforce/lds-bindings": "^1.104.1",
|
|
37
|
+
"@salesforce/lds-instrumentation": "^1.104.1",
|
|
38
|
+
"@salesforce/lds-priming": "^1.104.1",
|
|
39
39
|
"@salesforce/user": "0.0.12",
|
|
40
40
|
"o11y": "244.0.0"
|
|
41
41
|
},
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
"@luvio/engine": "0.135.4",
|
|
44
44
|
"@luvio/environments": "0.135.4",
|
|
45
45
|
"@luvio/graphql-parser": "0.135.4",
|
|
46
|
-
"@salesforce/lds-adapters-graphql": "^1.
|
|
47
|
-
"@salesforce/lds-drafts": "^1.
|
|
48
|
-
"@salesforce/lds-drafts-adapters-uiapi": "^1.
|
|
49
|
-
"@salesforce/lds-graphql-eval": "^1.
|
|
50
|
-
"@salesforce/lds-network-adapter": "^1.
|
|
51
|
-
"@salesforce/lds-network-nimbus": "^1.
|
|
52
|
-
"@salesforce/lds-store-binary": "^1.
|
|
53
|
-
"@salesforce/lds-store-sql": "^1.
|
|
54
|
-
"@salesforce/lds-utils-adapters": "^1.
|
|
55
|
-
"@salesforce/nimbus-plugin-lds": "^1.
|
|
46
|
+
"@salesforce/lds-adapters-graphql": "^1.104.1",
|
|
47
|
+
"@salesforce/lds-drafts": "^1.104.1",
|
|
48
|
+
"@salesforce/lds-drafts-adapters-uiapi": "^1.104.1",
|
|
49
|
+
"@salesforce/lds-graphql-eval": "^1.104.1",
|
|
50
|
+
"@salesforce/lds-network-adapter": "^1.104.1",
|
|
51
|
+
"@salesforce/lds-network-nimbus": "^1.104.1",
|
|
52
|
+
"@salesforce/lds-store-binary": "^1.104.1",
|
|
53
|
+
"@salesforce/lds-store-sql": "^1.104.1",
|
|
54
|
+
"@salesforce/lds-utils-adapters": "^1.104.1",
|
|
55
|
+
"@salesforce/nimbus-plugin-lds": "^1.104.1",
|
|
56
56
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
57
57
|
"wait-for-expect": "^3.0.2"
|
|
58
58
|
},
|
package/sfdc/main.js
CHANGED
|
@@ -4353,33 +4353,58 @@ function makeStoreEval(preconditioner, objectInfoService, userId, contextProvide
|
|
|
4353
4353
|
class AsyncWorkerPool {
|
|
4354
4354
|
constructor(concurrency) {
|
|
4355
4355
|
this.queue = [];
|
|
4356
|
-
this.
|
|
4356
|
+
this.activeWork = [];
|
|
4357
4357
|
this.concurrency = concurrency;
|
|
4358
4358
|
}
|
|
4359
|
-
push(
|
|
4359
|
+
push(work) {
|
|
4360
4360
|
return new Promise((resolve, reject) => {
|
|
4361
|
-
this.queue.push(
|
|
4362
|
-
|
|
4361
|
+
this.queue.push({
|
|
4362
|
+
...work,
|
|
4363
|
+
workFn: () => work.workFn().then(resolve).catch(reject),
|
|
4363
4364
|
});
|
|
4364
|
-
this.
|
|
4365
|
+
this.doWork();
|
|
4365
4366
|
});
|
|
4366
4367
|
}
|
|
4367
|
-
cancel() {
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
const
|
|
4375
|
-
if (
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4368
|
+
async cancel() {
|
|
4369
|
+
const promises = [];
|
|
4370
|
+
const cancellingWork = [
|
|
4371
|
+
...this.activeWork.splice(0, this.activeWork.length),
|
|
4372
|
+
...this.queue.splice(0, this.queue.length),
|
|
4373
|
+
];
|
|
4374
|
+
cancellingWork.forEach((work) => {
|
|
4375
|
+
const { cancelFn } = work;
|
|
4376
|
+
if (cancelFn) {
|
|
4377
|
+
promises.push(cancelFn());
|
|
4378
|
+
}
|
|
4379
|
+
});
|
|
4380
|
+
await promiseAllSettled(promises);
|
|
4381
|
+
}
|
|
4382
|
+
doWork() {
|
|
4383
|
+
while (this.queue.length > 0 && this.activeWork.length < this.concurrency) {
|
|
4384
|
+
const work = this.queue.shift();
|
|
4385
|
+
if (work) {
|
|
4386
|
+
this.activeWork.push(work);
|
|
4387
|
+
const { workFn } = work;
|
|
4388
|
+
workFn()
|
|
4389
|
+
.then()
|
|
4390
|
+
.finally(() => {
|
|
4391
|
+
this.activeWork = this.activeWork.filter((w) => w !== work);
|
|
4392
|
+
this.doWork();
|
|
4379
4393
|
});
|
|
4380
4394
|
}
|
|
4381
4395
|
}
|
|
4382
4396
|
}
|
|
4397
|
+
}
|
|
4398
|
+
function promiseAllSettled(promises) {
|
|
4399
|
+
return Promise.all(promises.map((promise) => promise
|
|
4400
|
+
.then((value) => ({
|
|
4401
|
+
status: 'fulfilled',
|
|
4402
|
+
value,
|
|
4403
|
+
}))
|
|
4404
|
+
.catch((reason) => ({
|
|
4405
|
+
status: 'rejected',
|
|
4406
|
+
reason,
|
|
4407
|
+
}))));
|
|
4383
4408
|
}
|
|
4384
4409
|
|
|
4385
4410
|
/**
|
|
@@ -4895,25 +4920,27 @@ class DurableDraftQueue {
|
|
|
4895
4920
|
});
|
|
4896
4921
|
}
|
|
4897
4922
|
async enqueue(handlerId, data) {
|
|
4898
|
-
return this.workerPool.push(
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
this.
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4923
|
+
return this.workerPool.push({
|
|
4924
|
+
workFn: async () => {
|
|
4925
|
+
let queue = await this.getQueueActions();
|
|
4926
|
+
const handler = this.getHandler(handlerId);
|
|
4927
|
+
const pendingAction = (await handler.buildPendingAction(data, queue));
|
|
4928
|
+
await this.draftStore.writeAction(pendingAction);
|
|
4929
|
+
queue = await this.getQueueActions();
|
|
4930
|
+
await this.notifyChangedListeners({
|
|
4931
|
+
type: DraftQueueEventType.ActionAdded,
|
|
4932
|
+
action: pendingAction,
|
|
4933
|
+
});
|
|
4934
|
+
await handler.handleActionEnqueued(pendingAction, queue);
|
|
4935
|
+
if (this.state === DraftQueueState.Started) {
|
|
4936
|
+
this.processNextAction();
|
|
4937
|
+
}
|
|
4938
|
+
const actionData = (await handler.getDataForAction(pendingAction));
|
|
4939
|
+
return {
|
|
4940
|
+
action: pendingAction,
|
|
4941
|
+
data: actionData,
|
|
4942
|
+
};
|
|
4943
|
+
},
|
|
4917
4944
|
});
|
|
4918
4945
|
}
|
|
4919
4946
|
registerOnChangedListener(listener) {
|
|
@@ -4926,28 +4953,30 @@ class DurableDraftQueue {
|
|
|
4926
4953
|
};
|
|
4927
4954
|
}
|
|
4928
4955
|
async actionCompleted(action) {
|
|
4929
|
-
return this.workerPool.push(
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4956
|
+
return this.workerPool.push({
|
|
4957
|
+
workFn: async () => {
|
|
4958
|
+
const handler = this.getHandler(action.handler);
|
|
4959
|
+
let queue = await this.getQueueActions();
|
|
4960
|
+
const queueOperations = handler.getQueueOperationsForCompletingDrafts(queue, action);
|
|
4961
|
+
const idAndKeyMappings = handler.getRedirectMappings(action);
|
|
4962
|
+
const keyMappings = idAndKeyMappings === undefined
|
|
4963
|
+
? undefined
|
|
4964
|
+
: idAndKeyMappings.map((m) => {
|
|
4965
|
+
return { draftKey: m.draftKey, canonicalKey: m.canonicalKey };
|
|
4966
|
+
});
|
|
4967
|
+
await this.draftStore.completeAction(queueOperations, keyMappings);
|
|
4968
|
+
queue = await this.getQueueActions();
|
|
4969
|
+
this.retryIntervalMilliseconds = 0;
|
|
4970
|
+
this.uploadingActionId = undefined;
|
|
4971
|
+
await handler.handleActionCompleted(action, queueOperations, queue, values$1(this.handlers));
|
|
4972
|
+
await this.notifyChangedListeners({
|
|
4973
|
+
type: DraftQueueEventType.ActionCompleted,
|
|
4974
|
+
action,
|
|
4938
4975
|
});
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
await handler.handleActionCompleted(action, queueOperations, queue, values$1(this.handlers));
|
|
4944
|
-
await this.notifyChangedListeners({
|
|
4945
|
-
type: DraftQueueEventType.ActionCompleted,
|
|
4946
|
-
action,
|
|
4947
|
-
});
|
|
4948
|
-
if (this.state === DraftQueueState.Started) {
|
|
4949
|
-
this.processNextAction();
|
|
4950
|
-
}
|
|
4976
|
+
if (this.state === DraftQueueState.Started) {
|
|
4977
|
+
this.processNextAction();
|
|
4978
|
+
}
|
|
4979
|
+
},
|
|
4951
4980
|
});
|
|
4952
4981
|
}
|
|
4953
4982
|
async actionFailed(action, retry) {
|
|
@@ -9082,7 +9111,9 @@ async function injectSyntheticFields(originalAST, objectInfoService, draftFuncti
|
|
|
9082
9111
|
if (node.name.value === 'where') {
|
|
9083
9112
|
const ancestorPath = findAncesterPath(ancestors);
|
|
9084
9113
|
if (idState.paths.includes(ancestorPath)) {
|
|
9085
|
-
const
|
|
9114
|
+
const apiName = objectInfoApiMap[ancestorPath][0];
|
|
9115
|
+
const objectInfo = objectInfos[apiName];
|
|
9116
|
+
const swappedIdFilter = swapIdField(node.value, objectInfo, false, idState, draftFunctions);
|
|
9086
9117
|
return {
|
|
9087
9118
|
...node,
|
|
9088
9119
|
value: swappedIdFilter,
|
|
@@ -9094,20 +9125,20 @@ async function injectSyntheticFields(originalAST, objectInfoService, draftFuncti
|
|
|
9094
9125
|
});
|
|
9095
9126
|
return { modifiedAST, objectInfos, unmappedDraftIDs: idState.unmappedDraftIDs };
|
|
9096
9127
|
}
|
|
9097
|
-
function swapIdField(filterFields, swapped, idState, draftFunctions) {
|
|
9128
|
+
function swapIdField(filterFields, objectInfo, swapped, idState, draftFunctions) {
|
|
9098
9129
|
switch (filterFields.kind) {
|
|
9099
9130
|
case Kind.OBJECT: {
|
|
9100
9131
|
const fieldNodes = [];
|
|
9101
9132
|
for (const fieldNode of filterFields.fields) {
|
|
9102
9133
|
if (isObjectValueNode(fieldNode.value)) {
|
|
9103
|
-
const fieldValue = swapIdField(fieldNode.value, fieldNode.name.value
|
|
9134
|
+
const fieldValue = swapIdField(fieldNode.value, objectInfo, isFieldAnIdField(fieldNode.name.value, objectInfo), idState, draftFunctions);
|
|
9104
9135
|
fieldNodes.push({
|
|
9105
9136
|
...fieldNode,
|
|
9106
9137
|
value: fieldValue,
|
|
9107
9138
|
});
|
|
9108
9139
|
}
|
|
9109
9140
|
else {
|
|
9110
|
-
const fieldValue = swapIdField(fieldNode.value, swapped, idState, draftFunctions);
|
|
9141
|
+
const fieldValue = swapIdField(fieldNode.value, objectInfo, swapped, idState, draftFunctions);
|
|
9111
9142
|
fieldNodes.push({
|
|
9112
9143
|
...fieldNode,
|
|
9113
9144
|
value: fieldValue,
|
|
@@ -9654,13 +9685,16 @@ function injectFilter(filterNode, idState, path, objectInfos, objectInfoApiMap,
|
|
|
9654
9685
|
throw new Error(`Field ${fieldName} does not exist in ${apiNames[0]}`);
|
|
9655
9686
|
}
|
|
9656
9687
|
}
|
|
9657
|
-
const
|
|
9688
|
+
const objectInfoName = objectInfoApiMap[curPath] !== undefined
|
|
9689
|
+
? objectInfoApiMap[curPath][0]
|
|
9690
|
+
: objectInfoApiMap[path][0];
|
|
9691
|
+
const isIdField = isFieldAnIdField(filterNode.name.value, objectInfos[objectInfoName]);
|
|
9658
9692
|
if (!isIdField) {
|
|
9659
9693
|
let subSelectionNodes = [];
|
|
9660
9694
|
let subFieldsHasId = false;
|
|
9661
9695
|
filterNode.value.fields.forEach((subFieldNode) => {
|
|
9662
9696
|
// Check if the filter field has the 'Id'
|
|
9663
|
-
if (subFieldNode.name.value
|
|
9697
|
+
if (isFieldAnIdField(subFieldNode.name.value, objectInfos[objectInfoName])) {
|
|
9664
9698
|
subFieldsHasId = true;
|
|
9665
9699
|
updateIDInfo(subFieldNode, idState, draftFunctions);
|
|
9666
9700
|
}
|
|
@@ -9826,6 +9860,12 @@ function mergeOrAddToGroup(group, element) {
|
|
|
9826
9860
|
}
|
|
9827
9861
|
group.push(element);
|
|
9828
9862
|
}
|
|
9863
|
+
function isFieldAnIdField(fieldName, objectInfo) {
|
|
9864
|
+
if (fieldName === 'Id')
|
|
9865
|
+
return true;
|
|
9866
|
+
const field = objectInfo.fields[fieldName];
|
|
9867
|
+
return field !== undefined ? field.dataType === 'Reference' : false;
|
|
9868
|
+
}
|
|
9829
9869
|
// produces a 'value' FieldNode if input query node does not contains the 'value' subnode
|
|
9830
9870
|
function produceValueFieldLeaves(queryNode) {
|
|
9831
9871
|
const existingValueFields = queryNode &&
|
|
@@ -9846,14 +9886,12 @@ function produceValueFieldLeaves(queryNode) {
|
|
|
9846
9886
|
: [];
|
|
9847
9887
|
}
|
|
9848
9888
|
function updateIDInfo(fieldNode, idState, draftFunctions) {
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
idState.swapNeeded = draftFunctions.isDraftId(id);
|
|
9856
|
-
}
|
|
9889
|
+
idState.swapNeeded = true;
|
|
9890
|
+
if (isObjectValueNode(fieldNode.value)) {
|
|
9891
|
+
const idOpValueNode = fieldNode.value.fields[0];
|
|
9892
|
+
if (isStringValueNode(idOpValueNode.value)) {
|
|
9893
|
+
const id = idOpValueNode.value.value;
|
|
9894
|
+
idState.swapNeeded = draftFunctions.isDraftId(id);
|
|
9857
9895
|
}
|
|
9858
9896
|
}
|
|
9859
9897
|
}
|
|
@@ -14854,44 +14892,48 @@ class PrimingSession extends EventEmitter {
|
|
|
14854
14892
|
// parallelizes batches of priming work
|
|
14855
14893
|
enqueueBatches(batches) {
|
|
14856
14894
|
for (const batch of batches) {
|
|
14857
|
-
this.networkWorkerPool.push(
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
|
|
14861
|
-
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
|
|
14865
|
-
|
|
14866
|
-
|
|
14867
|
-
|
|
14868
|
-
|
|
14869
|
-
const { missingIds } = result;
|
|
14870
|
-
if (missingIds.length > 0) {
|
|
14871
|
-
this.emit('error', {
|
|
14872
|
-
ids: missingIds,
|
|
14873
|
-
code: 'not-found',
|
|
14874
|
-
message: `could not find records: ${missingIds.join(', ')}`,
|
|
14875
|
-
});
|
|
14876
|
-
}
|
|
14877
|
-
const { records } = result;
|
|
14878
|
-
// dispatch the write but DO NOT wait on it to unblock the network pool
|
|
14879
|
-
this.recordIngestor.insertRecords(records).then(({ written, conflicted }) => {
|
|
14880
|
-
// now that the records are persisted, emit the primed event
|
|
14881
|
-
if (written.length > 0) {
|
|
14882
|
-
this.emit('primed', Array.from(written));
|
|
14895
|
+
this.networkWorkerPool.push({
|
|
14896
|
+
workFn: () => {
|
|
14897
|
+
return this.recordLoader.fetchRecordData(batch).then(async (result) => {
|
|
14898
|
+
if (result.ok === false) {
|
|
14899
|
+
const { error } = result;
|
|
14900
|
+
const primingError = error === 'network-error' ? 'service-unavailable' : 'unknown';
|
|
14901
|
+
this.emit('error', {
|
|
14902
|
+
ids: result.missingIds,
|
|
14903
|
+
code: primingError,
|
|
14904
|
+
message: `${result.messages.join(',')}`,
|
|
14905
|
+
});
|
|
14906
|
+
return;
|
|
14883
14907
|
}
|
|
14884
|
-
|
|
14885
|
-
if (
|
|
14886
|
-
// for now emit conlicts as errors
|
|
14908
|
+
const { missingIds } = result;
|
|
14909
|
+
if (missingIds.length > 0) {
|
|
14887
14910
|
this.emit('error', {
|
|
14888
|
-
ids:
|
|
14889
|
-
code: '
|
|
14890
|
-
message:
|
|
14911
|
+
ids: missingIds,
|
|
14912
|
+
code: 'not-found',
|
|
14913
|
+
message: `could not find records: ${missingIds.join(', ')}`,
|
|
14891
14914
|
});
|
|
14892
14915
|
}
|
|
14916
|
+
const { records } = result;
|
|
14917
|
+
// dispatch the write but DO NOT wait on it to unblock the network pool
|
|
14918
|
+
this.recordIngestor
|
|
14919
|
+
.insertRecords(records)
|
|
14920
|
+
.then(({ written, conflicted }) => {
|
|
14921
|
+
// now that the records are persisted, emit the primed event
|
|
14922
|
+
if (written.length > 0) {
|
|
14923
|
+
this.emit('primed', Array.from(written));
|
|
14924
|
+
}
|
|
14925
|
+
// TODO [W-12436213]: implement conflict resolution
|
|
14926
|
+
if (conflicted.length > 0) {
|
|
14927
|
+
// for now emit conlicts as errors
|
|
14928
|
+
this.emit('error', {
|
|
14929
|
+
ids: Array.from(conflicted),
|
|
14930
|
+
code: 'unknown',
|
|
14931
|
+
message: 'conflict when persisting record',
|
|
14932
|
+
});
|
|
14933
|
+
}
|
|
14934
|
+
});
|
|
14893
14935
|
});
|
|
14894
|
-
}
|
|
14936
|
+
},
|
|
14895
14937
|
});
|
|
14896
14938
|
}
|
|
14897
14939
|
}
|
|
@@ -15281,4 +15323,4 @@ register({
|
|
|
15281
15323
|
});
|
|
15282
15324
|
|
|
15283
15325
|
export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
|
|
15284
|
-
// version: 1.
|
|
15326
|
+
// version: 1.104.1-1e6c5b3e6
|