@salesforce/lds-runtime-mobile 1.289.0 → 1.291.0

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 CHANGED
@@ -54,7 +54,7 @@ const { join: join$2, push: push$2, unshift } = Array.prototype;
54
54
  const { isArray: isArray$5 } = Array;
55
55
  const { entries: entries$4, keys: keys$8 } = Object;
56
56
 
57
- const UI_API_BASE_URI = '/services/data/v61.0/ui-api';
57
+ const UI_API_BASE_URI = '/services/data/v62.0/ui-api';
58
58
 
59
59
  let instrumentation = {
60
60
  aggregateUiChunkCount: (_cb) => { },
@@ -9113,6 +9113,32 @@ async function readIngestionTimestampForKey(key, query) {
9113
9113
  return ingestionTimestamp;
9114
9114
  }
9115
9115
 
9116
+ // Code lifted from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
9117
+ // base64 character set, plus padding character (=)
9118
+ const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
9119
+ function btoaPolyfill(input) {
9120
+ let bitmap, a, b, c;
9121
+ let result = '', i = 0;
9122
+ const rest = input.length % 3; // To determine the final padding
9123
+ for (; i < input.length;) {
9124
+ if ((a = input.charCodeAt(i++)) > 255 ||
9125
+ (b = input.charCodeAt(i++)) > 255 ||
9126
+ (c = input.charCodeAt(i++)) > 255) {
9127
+ throw new TypeError('Failed base64ToAscii encoding: The string to be encoded contains characters outside of the Latin1 range. ' +
9128
+ input);
9129
+ }
9130
+ bitmap = (a << 16) | (b << 8) | c;
9131
+ result +=
9132
+ b64.charAt((bitmap >> 18) & 63) +
9133
+ b64.charAt((bitmap >> 12) & 63) +
9134
+ b64.charAt((bitmap >> 6) & 63) +
9135
+ b64.charAt(bitmap & 63);
9136
+ }
9137
+ // If there's need of padding, replace the last 'A's with equal signs
9138
+ return rest ? result.slice(0, rest - 3) + '==='.substring(rest) : result;
9139
+ }
9140
+ const base64encode = typeof btoa === 'function' ? btoa : btoaPolyfill;
9141
+
9116
9142
  function findSpanningField(name) {
9117
9143
  return (field) => {
9118
9144
  return (field.apiName === name ||
@@ -9394,6 +9420,11 @@ function addResolversToSchema(schema, polyFields) {
9394
9420
  return { recordRepresentation, ingestionTimestamp };
9395
9421
  };
9396
9422
  }
9423
+ else if (field.name === 'cursor') {
9424
+ field.resolve = function ({ index }) {
9425
+ return base64encode(`v1:${index}`);
9426
+ };
9427
+ }
9397
9428
  }
9398
9429
  }
9399
9430
  if (isRecordType(type)) {
@@ -9610,10 +9641,11 @@ async function connectionEdgeResolver(obj, _args, context) {
9610
9641
  //map each sql result with the ingestion timestamp to pass it down a level
9611
9642
  return results.rows
9612
9643
  .map((row) => row[0])
9613
- .map((record) => {
9644
+ .map((record, index) => {
9614
9645
  return {
9615
9646
  record,
9616
9647
  ingestionTimestamp,
9648
+ index,
9617
9649
  };
9618
9650
  });
9619
9651
  }
@@ -15461,7 +15493,7 @@ function mergePageUrls(first, second) {
15461
15493
  /**
15462
15494
  * merge to paging url with different set of fields or optional fields as combined one
15463
15495
  * the paging url is like
15464
- * /services/data/v61.0/ui-api/related-list-records/001R0000006l1xKIAQ/Contacts
15496
+ * /services/data/v62.0/ui-api/related-list-records/001R0000006l1xKIAQ/Contacts
15465
15497
  * ?fields=Id%2CName&optionalFields=Contact.Id%2CContact.Name&pageSize=50&pageToken=0
15466
15498
  * @param path1 url path and query parmeter without domain
15467
15499
  * @param path2 url path and query parmeter without domain
@@ -17725,7 +17757,7 @@ function instrumentPrimingSession(session) {
17725
17757
  // so eslint doesn't complain about nimbus
17726
17758
  /* global __nimbus */
17727
17759
  // note this is automatically incremented by scripts/release/bump-api-version.js at each release
17728
- const apiVersion = `v61.0`;
17760
+ const apiVersion = `v62.0`;
17729
17761
  const batchEndPointPath = `/services/data/${apiVersion}/graphql/batch`;
17730
17762
  const endPointPath = `/services/data/${apiVersion}/graphql`;
17731
17763
  const batchObjectInfoEndpoint = `/services/data/${apiVersion}/ui-api/object-info/batch`;
@@ -17907,6 +17939,20 @@ class SqlitePrimingStore {
17907
17939
  async writeBatch(records, overwrite) {
17908
17940
  const idsToPrime = new Set();
17909
17941
  const written = [];
17942
+ if (overwrite === true) {
17943
+ // if overwrite is true we need to raise change notifications so use the batchOperations
17944
+ const operations = {};
17945
+ for (const { record, metadata } of records) {
17946
+ const key = keyBuilderRecord(this.getLuvio(), { recordId: record.id });
17947
+ idsToPrime.add(record.id);
17948
+ operations[key] = {
17949
+ data: record,
17950
+ metadata: { ...metadata, metadataVersion: DURABLE_METADATA_VERSION },
17951
+ };
17952
+ }
17953
+ await this.store.setEntries(operations, DefaultDurableSegment);
17954
+ return { written: Array.from(idsToPrime), conflicted: [], errors: [] };
17955
+ }
17910
17956
  const statement = `${overwrite ? 'REPLACE' : 'INSERT or IGNORE'} INTO lds_data (key, data, metadata) VALUES ${records
17911
17957
  .map((_) => `(?,?,?)`)
17912
17958
  .join(',')} returning key;`;
@@ -18275,4 +18321,4 @@ register({
18275
18321
  });
18276
18322
 
18277
18323
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
18278
- // version: 1.289.0-5ba45a0a4
18324
+ // version: 1.291.0-8df6969f6
@@ -1,10 +1,10 @@
1
1
  import type { PrimingStore, RecordWithMetadata, WriteResult } from '@salesforce/lds-priming';
2
2
  import type { Luvio } from '@luvio/engine';
3
- import type { SqliteStore } from '@salesforce/lds-store-sql';
3
+ import type { NimbusSqliteStore } from '@salesforce/lds-store-nimbus';
4
4
  export declare class SqlitePrimingStore implements PrimingStore {
5
5
  private readonly getLuvio;
6
6
  private readonly store;
7
- constructor(getLuvio: () => Luvio, store: SqliteStore);
7
+ constructor(getLuvio: () => Luvio, store: NimbusSqliteStore);
8
8
  readRecords(ids: string[]): Promise<RecordWithMetadata[]>;
9
9
  writeRecords(records: RecordWithMetadata[], overwrite: boolean): Promise<WriteResult>;
10
10
  private writeBatch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.289.0",
3
+ "version": "1.291.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS runtime for mobile/hybrid environments.",
6
6
  "main": "dist/main.js",
@@ -32,25 +32,25 @@
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.289.0",
36
- "@salesforce/lds-bindings": "^1.289.0",
37
- "@salesforce/lds-instrumentation": "^1.289.0",
38
- "@salesforce/lds-priming": "^1.289.0",
35
+ "@salesforce/lds-adapters-uiapi": "^1.291.0",
36
+ "@salesforce/lds-bindings": "^1.291.0",
37
+ "@salesforce/lds-instrumentation": "^1.291.0",
38
+ "@salesforce/lds-priming": "^1.291.0",
39
39
  "@salesforce/user": "0.0.21",
40
40
  "o11y": "250.7.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@salesforce/lds-adapters-graphql": "^1.289.0",
44
- "@salesforce/lds-drafts": "^1.289.0",
45
- "@salesforce/lds-drafts-adapters-uiapi": "^1.289.0",
46
- "@salesforce/lds-graphql-eval": "^1.289.0",
47
- "@salesforce/lds-network-adapter": "^1.289.0",
48
- "@salesforce/lds-network-nimbus": "^1.289.0",
49
- "@salesforce/lds-store-binary": "^1.289.0",
50
- "@salesforce/lds-store-nimbus": "^1.289.0",
51
- "@salesforce/lds-store-sql": "^1.289.0",
52
- "@salesforce/lds-utils-adapters": "^1.289.0",
53
- "@salesforce/nimbus-plugin-lds": "^1.289.0",
43
+ "@salesforce/lds-adapters-graphql": "^1.291.0",
44
+ "@salesforce/lds-drafts": "^1.291.0",
45
+ "@salesforce/lds-drafts-adapters-uiapi": "^1.291.0",
46
+ "@salesforce/lds-graphql-eval": "^1.291.0",
47
+ "@salesforce/lds-network-adapter": "^1.291.0",
48
+ "@salesforce/lds-network-nimbus": "^1.291.0",
49
+ "@salesforce/lds-store-binary": "^1.291.0",
50
+ "@salesforce/lds-store-nimbus": "^1.291.0",
51
+ "@salesforce/lds-store-sql": "^1.291.0",
52
+ "@salesforce/lds-utils-adapters": "^1.291.0",
53
+ "@salesforce/nimbus-plugin-lds": "^1.291.0",
54
54
  "babel-plugin-dynamic-import-node": "^2.3.3",
55
55
  "wait-for-expect": "^3.0.2"
56
56
  },
@@ -59,7 +59,7 @@
59
59
  "path": "./dist/main.js",
60
60
  "maxSize": {
61
61
  "none": "800 kB",
62
- "min": "323.2 kB",
62
+ "min": "400 kB",
63
63
  "compressed": "150 kB"
64
64
  }
65
65
  },
@@ -67,7 +67,7 @@
67
67
  "path": "./sfdc/main.js",
68
68
  "maxSize": {
69
69
  "none": "800 kB",
70
- "min": "323.2 kB",
70
+ "min": "400 kB",
71
71
  "compressed": "150 kB"
72
72
  }
73
73
  }
package/sfdc/main.js CHANGED
@@ -54,7 +54,7 @@ const { join: join$2, push: push$2, unshift } = Array.prototype;
54
54
  const { isArray: isArray$5 } = Array;
55
55
  const { entries: entries$4, keys: keys$8 } = Object;
56
56
 
57
- const UI_API_BASE_URI = '/services/data/v61.0/ui-api';
57
+ const UI_API_BASE_URI = '/services/data/v62.0/ui-api';
58
58
 
59
59
  let instrumentation = {
60
60
  aggregateUiChunkCount: (_cb) => { },
@@ -9113,6 +9113,32 @@ async function readIngestionTimestampForKey(key, query) {
9113
9113
  return ingestionTimestamp;
9114
9114
  }
9115
9115
 
9116
+ // Code lifted from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
9117
+ // base64 character set, plus padding character (=)
9118
+ const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
9119
+ function btoaPolyfill(input) {
9120
+ let bitmap, a, b, c;
9121
+ let result = '', i = 0;
9122
+ const rest = input.length % 3; // To determine the final padding
9123
+ for (; i < input.length;) {
9124
+ if ((a = input.charCodeAt(i++)) > 255 ||
9125
+ (b = input.charCodeAt(i++)) > 255 ||
9126
+ (c = input.charCodeAt(i++)) > 255) {
9127
+ throw new TypeError('Failed base64ToAscii encoding: The string to be encoded contains characters outside of the Latin1 range. ' +
9128
+ input);
9129
+ }
9130
+ bitmap = (a << 16) | (b << 8) | c;
9131
+ result +=
9132
+ b64.charAt((bitmap >> 18) & 63) +
9133
+ b64.charAt((bitmap >> 12) & 63) +
9134
+ b64.charAt((bitmap >> 6) & 63) +
9135
+ b64.charAt(bitmap & 63);
9136
+ }
9137
+ // If there's need of padding, replace the last 'A's with equal signs
9138
+ return rest ? result.slice(0, rest - 3) + '==='.substring(rest) : result;
9139
+ }
9140
+ const base64encode = typeof btoa === 'function' ? btoa : btoaPolyfill;
9141
+
9116
9142
  function findSpanningField(name) {
9117
9143
  return (field) => {
9118
9144
  return (field.apiName === name ||
@@ -9394,6 +9420,11 @@ function addResolversToSchema(schema, polyFields) {
9394
9420
  return { recordRepresentation, ingestionTimestamp };
9395
9421
  };
9396
9422
  }
9423
+ else if (field.name === 'cursor') {
9424
+ field.resolve = function ({ index }) {
9425
+ return base64encode(`v1:${index}`);
9426
+ };
9427
+ }
9397
9428
  }
9398
9429
  }
9399
9430
  if (isRecordType(type)) {
@@ -9610,10 +9641,11 @@ async function connectionEdgeResolver(obj, _args, context) {
9610
9641
  //map each sql result with the ingestion timestamp to pass it down a level
9611
9642
  return results.rows
9612
9643
  .map((row) => row[0])
9613
- .map((record) => {
9644
+ .map((record, index) => {
9614
9645
  return {
9615
9646
  record,
9616
9647
  ingestionTimestamp,
9648
+ index,
9617
9649
  };
9618
9650
  });
9619
9651
  }
@@ -15461,7 +15493,7 @@ function mergePageUrls(first, second) {
15461
15493
  /**
15462
15494
  * merge to paging url with different set of fields or optional fields as combined one
15463
15495
  * the paging url is like
15464
- * /services/data/v61.0/ui-api/related-list-records/001R0000006l1xKIAQ/Contacts
15496
+ * /services/data/v62.0/ui-api/related-list-records/001R0000006l1xKIAQ/Contacts
15465
15497
  * ?fields=Id%2CName&optionalFields=Contact.Id%2CContact.Name&pageSize=50&pageToken=0
15466
15498
  * @param path1 url path and query parmeter without domain
15467
15499
  * @param path2 url path and query parmeter without domain
@@ -17725,7 +17757,7 @@ function instrumentPrimingSession(session) {
17725
17757
  // so eslint doesn't complain about nimbus
17726
17758
  /* global __nimbus */
17727
17759
  // note this is automatically incremented by scripts/release/bump-api-version.js at each release
17728
- const apiVersion = `v61.0`;
17760
+ const apiVersion = `v62.0`;
17729
17761
  const batchEndPointPath = `/services/data/${apiVersion}/graphql/batch`;
17730
17762
  const endPointPath = `/services/data/${apiVersion}/graphql`;
17731
17763
  const batchObjectInfoEndpoint = `/services/data/${apiVersion}/ui-api/object-info/batch`;
@@ -17907,6 +17939,20 @@ class SqlitePrimingStore {
17907
17939
  async writeBatch(records, overwrite) {
17908
17940
  const idsToPrime = new Set();
17909
17941
  const written = [];
17942
+ if (overwrite === true) {
17943
+ // if overwrite is true we need to raise change notifications so use the batchOperations
17944
+ const operations = {};
17945
+ for (const { record, metadata } of records) {
17946
+ const key = keyBuilderRecord(this.getLuvio(), { recordId: record.id });
17947
+ idsToPrime.add(record.id);
17948
+ operations[key] = {
17949
+ data: record,
17950
+ metadata: { ...metadata, metadataVersion: DURABLE_METADATA_VERSION },
17951
+ };
17952
+ }
17953
+ await this.store.setEntries(operations, DefaultDurableSegment);
17954
+ return { written: Array.from(idsToPrime), conflicted: [], errors: [] };
17955
+ }
17910
17956
  const statement = `${overwrite ? 'REPLACE' : 'INSERT or IGNORE'} INTO lds_data (key, data, metadata) VALUES ${records
17911
17957
  .map((_) => `(?,?,?)`)
17912
17958
  .join(',')} returning key;`;
@@ -18275,4 +18321,4 @@ register({
18275
18321
  });
18276
18322
 
18277
18323
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
18278
- // version: 1.289.0-5ba45a0a4
18324
+ // version: 1.291.0-8df6969f6
@@ -1,10 +1,10 @@
1
1
  import type { PrimingStore, RecordWithMetadata, WriteResult } from '@salesforce/lds-priming';
2
2
  import type { Luvio } from '@luvio/engine';
3
- import type { SqliteStore } from '@salesforce/lds-store-sql';
3
+ import type { NimbusSqliteStore } from '@salesforce/lds-store-nimbus';
4
4
  export declare class SqlitePrimingStore implements PrimingStore {
5
5
  private readonly getLuvio;
6
6
  private readonly store;
7
- constructor(getLuvio: () => Luvio, store: SqliteStore);
7
+ constructor(getLuvio: () => Luvio, store: NimbusSqliteStore);
8
8
  readRecords(ids: string[]): Promise<RecordWithMetadata[]>;
9
9
  writeRecords(records: RecordWithMetadata[], overwrite: boolean): Promise<WriteResult>;
10
10
  private writeBatch;